eolymp
bolt
Try our new interface for solving problems
Problems

Количество путей

Количество путей

The oriented graph without cycles is given. Разбить граф на минимальное количество вершинно-непересекающихся путей. То есть каждая вершина должна принадлежать ровно одному пути.

Input

The first line contains the number of vertices n and edges k (1n500, 0kn ·(n - 1) / 2) in the graph. Each of the next k lines contains two integers - a, b (1a, bn), giving the description of an edge from vertex a to vertex b. Each pair (a, b) appears no more than one time.

Output

Print the minimal possible number of paths.

Time limit 1 second
Memory limit 122.17 MiB
Input example #1
7 6
1 4
2 4
3 4
4 5
4 6
4 7
Output example #1
5
Source III International Summer School Programming in Sevastopol 2012