There is a directed graph G with N vertices and M edges. The vertices are numbered 1, 2, \ldots, N, and for each i (1 \leq i \leq M), the i-th directed edge goes from Vertex x_i to y_i. G does not contain directed cycles.

Find the length of the longest directed path in G. Here, the length of a directed path is the number of edges in it.

Constraints

* All values in input are integers.
* 2 \leq N \leq 10^5
* 1 \leq M \leq 10^5
* 1 \leq x_i, y_i \leq N
* All pairs (x_i, y_i) are distinct.
* G does not contain directed cycles.

Input

Input is given from Standard Input in the following format:


N M
x_1 y_1
x_2 y_2
:
x_M y_M


Output

Print the length of the longest directed path in G.

Examples

Input

4 5
1 2
1 3
3 2
2 4
3 4


Output

3


Input

6 3
2 3
4 5
5 6


Output

2


Input

5 8
5 3
2 3
2 4
5 2
5 1
1 4
4 3
1 3


Output

3
import java.util.*;
import java.io.*;

/*
 * G - LP
 */
public class Main
{
private Map< Integer, List< Integer >> m;
private Set< Integer > fromSet;
private Map< Integer, Integer > cache;

public static void main( String[] args ) throws Exception
{
	new Main().run();
}

public void run() throws Exception
{
	final Scanner sc = new Scanner( getInputStream() );
	final int N = sc.nextInt();
	final int M = sc.nextInt();
	
	m = new HashMap<>(N*2);
	fromSet = new HashSet<>(N*2);
	cache = new HashMap<>(N*2);

	for( int i = 0; i < M; ++i )
	{
		int from = sc.nextInt();
		int to = sc.nextInt();

		List< Integer > list = m.get( to );
		if( list == null )
		{
			list = new ArrayList<>();
			m.put( to, list );
		}
		list.add( from );
		fromSet.add( from );
	}
	//p( fromSet );
	Set< Integer > toSet = new HashSet<>( m.keySet() );
	toSet.removeAll( fromSet );
	//p( toSet );
	//p( m );

	//全ての最終ノード候補についてループ
	int max = 0;
	for( final Integer lastNode : toSet )
	{
		int lp = getLP( lastNode );
		if( max < lp )
		{
			max = lp;
		}
	}
	p( max );
}

public int getLP( final int to )
{
	Integer cachedValue = cache.get( to );
	if( cachedValue != null )
	{
		return cachedValue.intValue();
	}
	else
	{
		int max = 0;
		final List< Integer > list = m.get( to );
		if( list != null )
		{
			for( Integer i : list )
			{
				int lp = getLP( i );
				if( max < lp )
				{
					max = lp;
				}
			}
			max += 1;
		}
		cache.put( to, max );
		return max;
	}
}

public static void p( Object o )
{
	System.out.println( o );
}

public static InputStream getInputStream() throws IOException
{
	//p( System.getProperties() );
	if( System.getProperty( "test" ) != null )
	{
		return new FileInputStream( "1" );
	}
	else
	{
		return System.in;
	}
}

}
