Under construction

Still being built. Things may change

Virus

Interview

Time limit1sMemory limit128 MB

Summary
Count how many computers other than computer 1 lie in computer 1's connected component of a small undirected graph.
Level

Easy2 of 10

Topics
Graph, BFS, DFS
Solved
No attempts yet

Problem

A worm virus spreads along network connections. If one computer is infected, every computer in the same connected component can become infected.

Computer 1 is infected. Given the number of computers and the pairs of computers directly connected by the network, determine how many other computers become infected through computer 1.

Do not count computer 1 itself.

Input

The first line contains the number of computers N. N is a positive integer no greater than 100, and the computers are numbered from 1 to N.

The second line contains the number M of pairs of computers that are directly connected in the network. Each of the next M lines contains two computer numbers a and b that are directly connected.

Output

Print one integer: the number of computers other than computer 1 that become infected through computer 1.

Examples1

  1. Example 1

    Input
    7
    6
    1 2
    2 3
    1 5
    5 2
    5 6
    4 7
    
    Expected output
    4