Tabby, Teddy's sister, wants to perform some direct-mail promotions! She lives in the country of Byteland, which consists of cities numbered from to inclusive. These cities are connected by bidirectional roads. Tabby can access a post office in city , and the post office can deliver to any city as long as there is a path from the post office to that city via some of the roads. To estimate the effectiveness of the promotion, Tabby wants to figure out how many cities the post office can deliver to (including its own city). Can you help her?
Constraints
Input Specification
The first line will contain three integers , , and : the number of cities, the number of bidirectional roads, and the city that Tabby's post office is located in.
The next lines will each contain two integers and , indicating that there is a bidirectional road between city and city
Output Specification
One integer, the number of cities that the post office can deliver to
Sample Input
7 6 2
1 6
3 6
2 7
4 7
2 4
7 5
Sample Output
4
Sample Explanation
The graph looks as such:
When looking at city , we see that it is connected to cities in total: cities , , , and . Thus, the post office can deliver to cities.
Comments