St Andrews Online Judge

Friend and Friend of Friend

By Kay Akashi

Time: 1000 ms
Memory: 256000 kB

The code judging system is only available during contests. Check out the github repo for test cases and solutions.

Please log in.

Problem Statement

On the social media platform Imstagran, you are assigned an index xx (1xn)(1 \leq x \leq n). You are going to be a friend with a certain number of people amongst (n1)(n - 1) people each of which is assigned an index ranging from 11 to nn but not xx (i.e.i.e. People including you are assigned distinct indices from 11 to nn).

In mm lines you are given aia_i and bib_i (1im)(1 \leq i \leq m) indicating that aia_i and bib_i are friends on Imstagran. Now, you are asked to count the number of people who are either "your friends" or "friends of your friends". Clearly, you yourself are "a friend of your friend" hence counted, only if you have any friend. If you are "lonely enough" (i.e.i.e. you don't have a single friend), you are NOT "a friend of your friend" hence not counted, sadly.

Note that, unlike Imstagran's rival social media Instagram, it never happens that one follows another but not followed back. On Imstagran, two people are friends and they bilaterally follow each other.

Constraints

2n,m1042 \leq n, m \leq 10^{4}, 1ai,bin1 \leq a_i, b_i \leq n (1im)(1 \leq i \leq m).

Input

The first line of input contains three integers, nn, xx, and mm. Following are mm lines each of which consists of ai,bia_i, b_i (1ai,bin)(1 \leq a_i, b_i \leq n), (1im)(1 \leq i \leq m).

Output

Output the answer.

Examples

Input

4 2 3
1 4
2 4
2 3

Output

4

Explanation

You can see that 33 and 44 are your friends. You, whose index is 22, are a friend of 11 and 22. Also, 11 is a friend of your friend 44, hence a friend of your friend. All people here meet the condition, thus the answer is 44.

Input

5 1 2
3 4
4 5

Output

0

Explanation

You have no friend. Because you have no friend, there're no friends of your friend. The answer is 00.