#graph903. 祭祀

祭祀

Sacrifice

Problem Source

CTSC 2008

Problem Description

In the far east lives a mysterious ethnic group that calls itself the Y tribe. They have lived on the water for generations and worship the Dragon King as their god. On every major festival the Y tribe holds grand sacrifice ceremonies on the water. Their habitat's water system can be viewed as a network of junctions and channels; each channel connects two junctions, and water always flows in a fixed direction along a channel. Clearly, the water system contains no cycles.

Because of their large population, the Y tribe's sacrifices are held simultaneously at multiple junctions. Out of respect for the Dragon King, the choice of these sacrifice sites must be made very carefully. Precisely: the Y tribe believes that if water can flow from one sacrifice site to another, the sacrifice loses its sacred meaning. The tribal chief wants to choose as many sacrifice sites as possible while keeping the ceremonies sacred.

Input Format

The first line contains two space-separated integers n,m (1≤n≤100,1≤m≤1000)n, m\ (1 \le n \le 100, 1 \le m \le 1000), the number of junctions and channels, with junctions numbered 11 through nn.

Each of the next mm lines contains two space-separated integers u,vu, v, describing a channel connecting junctions uu and vv with water flowing from uu to vv.

Output Format

The first line contains one integer kk: the maximum number of sacrifice sites that can be chosen.

Sample Input

4 4
1 2
3 4
3 2
4 2

Sample Output

2