QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 128 MB

#23367. Virus

統計

A new virus called a worm spreads through a network. When a computer becomes infected with the worm, all computers connected to it through the network become infected as well.

For example, suppose seven computers are connected as in Figure 1. If computer 1 is infected, the worm spreads through computers 2 and 5 to computers 3 and 6, infecting the four computers 2, 3, 5, and 6. However, computers 4 and 7 are unaffected because they are not connected to computer 1 through the network.

problem_23367_59082b7e2ece9da1b5eb568c85cadcd7.png

One day, computer 1 became infected with the worm. Given the number of computers and information about their network connections, write a program that prints the number of computers that become infected through computer 1.

Input

The first line contains the number of computers. There are at most 100 computers, numbered consecutively starting from 1.

The second line contains the number of pairs of computers directly connected through the network.

That many lines follow, each containing the numbers of one pair of directly connected computers.

Output

Print on the first line the number of computers that become infected through computer 1 when computer 1 is infected with the worm.

Examples

Input 1

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

Output 1

4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.