Longest path
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 256 megabytes
Given a directed acyclic graph, the task is to find the longest path in it.
Input
The first line of the input file contains two natural numbers and - the number of vertices and arcs in the graph, respectively . The next lines contain descriptions of the arcs, one per line. Arc number is described by two natural numbers and - the start and end of the arc, respectively .
The input graph contains no cycles or loops.
Output
The first line of the output file should contain a single natural number - the number of arcs in the longest path.
Examples
Input #1
Answer #1
Submissions 510
Acceptance rate 29%