{"raw_statement":[{"iden":"problem statement","content":"There is a directed graph $G$ with $N$ vertices and $M$ edges. The vertices are numbered $1, 2, \\ldots, N$, and for each $i$ ($1 \\leq i \\leq M$), the $i$\\-th directed edge goes from Vertex $x_i$ to $y_i$. $G$ **does not contain directed cycles**.\nFind the length of the longest directed path in $G$. Here, the length of a directed path is the number of edges in it."},{"iden":"constraints","content":"*   All values in input are integers.\n*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq M \\leq 10^5$\n*   $1 \\leq x_i, y_i \\leq N$\n*   All pairs $(x_i, y_i)$ are distinct.\n*   $G$ **does not contain directed cycles**."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $M$\n$x_1$ $y_1$\n$x_2$ $y_2$\n$:$\n$x_M$ $y_M$"},{"iden":"sample input 1","content":"4 5\n1 2\n1 3\n3 2\n2 4\n3 4"},{"iden":"sample output 1","content":"3\n\nThe red directed path in the following figure is the longest:\n![image](https://img.atcoder.jp/dp/longest_0_muffet.png)"},{"iden":"sample input 2","content":"6 3\n2 3\n4 5\n5 6"},{"iden":"sample output 2","content":"2\n\nThe red directed path in the following figure is the longest:\n![image](https://img.atcoder.jp/dp/longest_1_muffet.png)"},{"iden":"sample input 3","content":"5 8\n5 3\n2 3\n2 4\n5 2\n5 1\n1 4\n4 3\n1 3"},{"iden":"sample output 3","content":"3\n\nThe red directed path in the following figure is one of the longest:\n![image](https://img.atcoder.jp/dp/longest_2_muffet.png)"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}