LearnPy Hub
← Arena
AdvancedRating 1600

Longest Path in a DAG

The directed graph has no cycles. Print the number of edges on its longest path.

Input

n and m; then m lines 'u v' (edge u → v).

Output

One integer.

Sample 1

Input
4 5
1 2
1 3
3 2
2 4
3 4
Output
3

Sample 2

Input
2 0
Output
0
solution.py
Output appears here
Longest Path in a DAG · Python Arena problem · LearnPy Hub