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.

Submit: 590 Solved: 161

[Submit][Status][Web Board]

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.

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 one integer as your answer.

```
5000 2 238
3212 238
238 3212
```

`4998`