 Code Submission Evaluation System Login

# HIIT Open 2017

 Start: 2017-05-27 11:00:00 End: 2017-05-27 16:00:00

CSES - HIIT Open 2017 - FactoryCSES - Factory

## 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
• $1 \le n \le 500$
• $0 \le m \le \frac{n(n-1)}{2}$
Example

Input:
3 2 1 2 1 3

Output:
2