Acyclic Decomposition

No attempts yetTime limit2sMemory limit512 MB

Problem

Byteman is studying directed graphs. He is especially fond of graphs that contain no directed cycles, because on such graphs many problems can be solved simply and efficiently. He now wants a way to represent any directed graph as a combination of acyclic graphs.

Given a directed graph, partition its set of edges into as few subsets as possible so that, for every subset, the directed graph formed by only those edges contains no directed cycle. Your task is to report that smallest possible number of subsets.

Input

The first line contains two integers nn and mm (1n,m100,0001 \le n, m \le 100{,}000): the number of vertices and the number of edges. The vertices are numbered from 11 to nn. Each of the next mm lines contains two integers aia_i and bib_i (1ai,bin1 \le a_i, b_i \le n, aibia_i \ne b_i), describing a directed edge from vertex aia_i to vertex bib_i. The graph contains no multiple edges.

Output

Print a single integer: the minimum number of acyclic subgraphs into which the edge set of the graph can be partitioned.

Hint

The picture illustrates the example. The circles are vertices and the lines and arcs (solid and dashed) are edges. The number next to each circle is the vertex number, and the number next to each line or arc is the edge number. The edges of this graph can be split into two acyclic graphs: the solid edges form the first one and the dashed edges form the second, so the answer for this graph is 22.