Strong connectivity#510

Strong connectivity

1 second
128 megabytes
Medium (≈1350)

A strongly connected component in a directed graph is a set of vertices such that there is a path from any vertex to any other vertex in the set. Moreover, there is no larger set with this property containing this set.

Given a directed graph. Find the number of strongly connected components.

Input

The first line contains two integers and m~(1 \le n \le 10, 0 \le m \le 90) — the number of vertices and edges in the graph, respectively. The next lines describe the edges: the -th line contains two integers u_i and v_i~(1 \le u_i, v_i \le n) — the start and the end of the -th edge respectively. It is guaranteed that the graph has no loops or multiple edges.

Output

Print the number of strongly connected components in the graph.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading