# Minimum Police for Surveillance
## Problem Statement
The city of Graphopolis consists of $n$ intersections (numbered from $1$ to $n$) and $m$ one-way roads connecting them. Due to recent incidents, the city needs to place police officers to monitor all intersections.
A police officer placed at an intersection $u$ can monitor intersection $u$ itself, and all intersections $v$ such that there is a path from $u$ to $v$ following the one-way roads.
Your task is to determine the minimum number of police officers needed to ensure that every intersection is monitored.
## Input Format
- The first line contains two integers $n$ and $m$ ($1 \le n \le 10^5$, $0 \le m \le 10^5$).
- $n$: the number of intersections.
- $m$: the number of one-way roads.
- The next $m$ lines each contain two integers $u$ and $v$ ($1 \le u, v \le n$), denoting a one-way road from intersection $u$ to intersection $v$.
## Output Format
Print a single integer — the minimum number of police officers needed.
## Sample Test Cases
### Sample Input 1
```
6 6
1 2
2 3
3 1
4 5
5 6
6 4
```
### Sample Output 1
```
2
```
### Sample Input 2
```
3 2
1 2
2 3
```
### Sample Output 2
```
1
```
## Constraints
- $1 \le n \le 10^5$
- $0 \le m \le 10^5$
- There are no self-loops (i.e., no road from $u$ to $u$, so $u \ne v$ for any road $(u, v)$) or multiple edges between the same pair of intersections.
- Time limit: 1 second
- Memory limit: 256 MB
## Explanation
### Sample 1 Explanation
Consider the given intersections and roads:
Roads: $1 \to 2$, $2 \to 3$, $3 \to 1$, $4 \to 5$, $5 \to 6$, $6 \to 4$.
We can observe two distinct groups of intersections where officers can monitor each other:
1. Intersections $ \{1, 2, 3\} $:
- If an officer is placed at $1$, they monitor $1$ (itself).
- Since there's a path $1 \to 2$, they also monitor $2$.
- Since there's a path $1 \to 2 \to 3$, they also monitor $3$.
- Thus, one officer at $1$ can monitor all of $ \{1, 2, 3\} $.
2. Intersections $ \{4, 5, 6\} $:
- Similarly, if an officer is placed at $4$, they monitor $4$, and through paths $4 \to 5$ and $4 \to 5 \to 6$, they also monitor $5$ and $6$.
- Thus, one officer at $4$ can monitor all of $ \{4, 5, 6\} $.
Since there are no roads connecting intersections from $ \{1, 2, 3\} $ to $ \{4, 5, 6\} $ or vice-versa, these two groups must be monitored independently. Therefore, we need a minimum of $1$ officer for $ \{1, 2, 3\} $ and $1$ officer for $ \{4, 5, 6\} $, totaling $2$ officers.
### Sample 2 Explanation
Consider the given intersections and roads:
Roads: $1 \to 2$, $2 \to 3$.
If we place a police officer at intersection $1$:
- They monitor $1$ (itself).
- Since there is a road $1 \to 2$, intersection $2$ is monitored.
- Since there is a path $1 \to 2 \to 3$, intersection $3$ is monitored.
Thus, a single officer placed at intersection $1$ can monitor all intersections $1, 2, 3$. No fewer than one officer can monitor all intersections, so the minimum number is $1$.
Loading problem statement...