Code Submission Evaluation System Login

CSES - HIIT Open 2017

HIIT Open 2017

Contest start:2017-05-27 11:00:00
Contest end:2017-05-27 16:00:00

Task list | Submit code | Submissions | Messages | Scoreboard


Factory

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 $n$ jobs to be done. For some jobs $a$ and $b$ it is known that $a$ must be done before $b$.

What is the minimum number of days needed to do all the jobs?

Input

The first input line contains two integers $n$ and $m$: the number of jobs and the number of relations. The jobs are numbered $1,2,\ldots,n$.

After this, there are $m$ lines that describe the relations. Each line contains two integers $a$ and $b$: job $a$ must be done before job $b$.

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