CSES - Flight Route Requests
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There are nn cities with airports but no flight connections. You are given mm requests which routes should be possible to travel.

Your task is to determine the minimum number of one-way flight connections which makes it possible to fulfil all requests.

Input

The first input line has two integers nn and mm: the number of cities and requests. The cities are numbered 1,2,,n1,2,\dots,n.

After this, there are mm lines describing the requests. Each line has two integers aa and bb: there has to be a route from city aa to city bb. Each request is unique.

Output

Print one integer: the minimum number of flight connections.

Constraints

  • 1n1051 \le n \le 10^5
  • 1m21051 \le m \le 2 \cdot 10^5
  • 1a,bn1 \le a, b \le n

Example

Input:

4 5
1 2
2 3
2 4
3 1
3 4

Output:

4

Explanation: You can create the connections 121 \rightarrow 2, 232 \rightarrow 3, 242 \rightarrow 4 and 313 \rightarrow 1. Then you can also fly from city 33 to city 44 using the route 31243 \rightarrow 1 \rightarrow 2 \rightarrow 4.