J. 8M
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

March 8th (8M) is a very important date for any woman, and Mar knows it. Although she felt very nervous about attending a march, she was always drawn to it, and this year she finally dared to go for the first time, motivated by her group of friends.

Upon arriving, she was amazed by the huge number of women filling the streets, and then she noticed something special: some women held ribbons tied to another's wrist, and some had ribbons tied back, representing their union. If a girl $$$A$$$ tied a ribbon to a girl $$$B$$$, then following the ribbons, $$$A$$$ can reach $$$B$$$, and from $$$B$$$ she can keep going to every woman that $$$B$$$ reaches.

Mar considers a group of women to be united if, following the direction of the ribbons, every member can reach every other member.

Mar notices that, although there are many ribbons, the women of the march are not united. She wants to know the minimum number of additional ribbons that must be tied so that all the women in the march form a single united group.

Input

The first line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \le N \le 2 \cdot 10^5, 0 \le M \le 2 \cdot 10^5$$$), representing the number of women in the march and the number of initial ribbon connections, respectively. The women are numbered from $$$1$$$ to $$$N$$$.

The following $$$M$$$ lines contain two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le N$$$), indicating that woman $$$u$$$ has tied a ribbon to woman $$$v$$$ (the ribbon can only be followed in that direction). There can be multiple ribbons between the same pair of women, and even a woman with a ribbon tied to herself.

Output

Print a single integer, the minimum number of additional ribbons that must be added (tied with a direction) so that all the women in the march form a single united group.

Examples
Input
3 2
1 2
2 3
Output
1
Input
3 3
1 2
2 3
3 1
Output
0
Note

In the first example, assuming women $$$1, 2, 3$$$, if we add a ribbon from woman 3 to woman 1, then every woman can reach every other woman, so the three of them become united.

In the second example, every woman can already reach every other woman, so the answer is 0.