15111511 SUSTech Online Judge
Problem 1511 --Simple Problem

## 1511: Simple Problem

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 590  Solved: 161
[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

[Submit][Status]