CSES - HIIT Open 2017 - 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 nn jobs to be done. For some jobs aa and bb it is known that aa must be done before bb.

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

Input

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

After this, there are mm lines that describe the relations. Each line contains two integers aa and bb: job aa must be done before job bb.

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

  • 1n5001 \le n \le 500
  • 0mn(n1)20 \le m \le \frac{n(n-1)}{2}

Example

Input:

3 2
1 2
1 3

Output:

2