oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

party Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

party.html

You have decided to throw a party! Since a one-person party is quite no-life, you have decided to invite all your friends along! In addition, they have also invited their friends along as well. However, to prevent your house from overflowing with people, you have decided to draw the line there, friends-of-friends are the farthest you will go. Now, you want to find out exactly how many people are going down for your party (excluding yourself).

Given the number of people N as well as details of M friendships, output the number of people excluding yourself going down for your party. Note: Friendship is mutual! We aren't stalkers here :)

Input

The first line of input will contain N, the number of people (2 ≤ N ≤ 500). You are person 1.

The second line of input will contain M, the number of friendships (1 ≤ M ≤ 10,000).

The next M lines of input will contain two integers a and b, indicating that a and b are friends (1 ≤ a,b ≤ N). Remember, no stalking!

Output

Output one integer, the number of people going down for your party excluding yourself

Sample Input 1

6
5
1 2
1 3
3 4
2 3
5 4

Sample Output 1

3

Sample Input 2

6
5
2 3
4 3
5 4
5 6
2 5

Sample Output 2

0

Tags

Graph Theory

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
110051s32MBAverage
2021s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o party -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.