15111511 SUSTech Online Judge
Problem 1511 --Simple Problem

1511: Simple Problem

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 592  Solved: 162
[Submit][Status][Web Board]

Description

Given a directed graph of \(n\) vertices with \(m\) edges and a vertex \(S\) , Tenshi wants you to find the minimum number of directed edges that can be added so that \(S\) can reach all vertices on the graph.


Input

The first line of input consists of three integers \(n, m, S\) . Here, \(1≤n≤50000,0≤m≤50000,1≤S≤n\)

       The following \(m\) lines contain directed edges: edge is given as a pair of vertices \(u_i, v_i\)

Output

Output one integer as your answer.

Sample Input

5000 2 238
3212 238
238 3212

Sample Output

4998

HINT

Source

 

[Submit][Status]