- Time limit: 1.00 s
- Memory limit: 512 MB
There are two machines in a factory. Both machines can do one job in a day, and they can work simultaneously.
There are a total of jobs to be done. For some jobs and it is known that must be done before .
What is the minimum number of days needed to do all the jobs?
Input
The first input line contains two integers and : the number of jobs and the number of relations. The jobs are numbered .
After this, there are lines that describe the relations. Each line contains two integers and : job must be done before job .
Output
Print one integer: the minimum number of days needed to do all the jobs.
You can assume that there is a way to do all the jobs.
Constraints
Example
Input:
3 2 1 2 1 3
Output:
2