Under construction

Still being built. Things may change

Ringteed

Time limit1sMemory limit1024 MB

Summary
Count the squares where a simple walk starting at square S can end in a connected graph whose cycles share no vertices.
Level

Hard8 of 10

Topics
Graph, DFS, Tree
Solved
No attempts yet

Problem

Bit, a boy who likes to walk around his home city, lives in Bytetown, the capital of Byteland.

The road network of Bytetown consists of NN squares connected by MM streets. From any square, one can reach every other square along the streets.

If, starting from some square, one can move along streets and return to that same square without visiting any square or street twice on the way, the route is called a ring road. A notable property of Bytetown's network is that no square lies on more than one ring road.

Bit has just come up with a new plan for how he will walk from now on. Each day he steps out of his house onto the square in front of it. He picks a street starting there and follows it to the next square, where he picks another street to continue. During one walk he never visits the same square twice. He keeps walking until he reaches a square from which every street leads to a square he has already visited. Then he declares the walk finished and takes the bus home.

Write a program that finds the number of different squares where Bit's walks can end.

Input

The first line contains the space-separated integers NN, MM, and SS: the number of squares, the number of streets, and the number of the square in front of Bit's house. The constraints are 2≤N≤200 0002 \le N \le 200\,000, N−1≤M≤43NN-1 \le M \le \frac{4}{3}N, and 1≤S≤N1 \le S \le N.

Each of the next MM lines contains two integers AiA_i and BiB_i (1≤Ai≤N1 \le A_i \le N, 1≤Bi≤N1 \le B_i \le N, Ai≠BiA_i \ne B_i), meaning there is a street between squares AiA_i and BiB_i. Any two squares are connected by at most one street.

Output

Print a single integer: the number of squares where Bit's walks can end.

Examples2

  1. Example 1

    Input
    3 2 2
    1 2
    2 3
    
    Expected output
    2
    
  2. Example 2

    Input
    4 4 3
    1 2
    2 3
    3 4
    4 1
    
    Expected output
    2