Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of its nervous system. More precisely, we define the distance between two brains u and v (1 ≤ u, v ≤ n) as the minimum number of brain connectors used when transmitting a thought between these two brains. The brain latency of a zombie is defined to be the maximum distance between any two of its brains. Researchers conjecture that the brain latency is the crucial parameter which determines how smart a given zombie is. Help them test this conjecture by writing a program to compute brain latencies of nervous systems.

In this problem you may assume that any nervous system given in the input is valid, i.e., it satisfies conditions (1) and (2) from the easy version.

Input

The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 100000) denoting the number of brains (which are conveniently numbered from 1 to n) and the number of brain connectors in the nervous system, respectively. In the next m lines, descriptions of brain connectors follow. Every connector is given as a pair of brains a b it connects (1 ≤ a, b ≤ n and a ≠ b).

Output

Print one number – the brain latency.

Examples

Input

4 3
1 2
1 3
1 4


Output

2

Input

5 4
1 2
2 3
3 4
3 5


Output

3
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		new C2().solve();
	}
}

class C2 {

	InputReader in = new InputReader(System.in);
	PrintWriter out = new PrintWriter(System.out);
    
	final int N = 100008 ;
	class E{
		int v ;
		int next ;
		E(int v , int next){
			this.v = v ;
			this.next = next ;
		}
	}
	E[] e = new E[N*2] ;
	int[] head = new int[N] ;
	int eid ;
	void add(int u , int v){
		e[eid] = new E(v, head[u]) ;
		head[u] = eid++ ;
		e[eid] = new E(u, head[v]) ;
		head[v] = eid++ ;
	}
	int n , m ;
	
	class Node{
		int u ;
		int dist ;
		Node(int u , int dist){
			this.u = u ;
			this.dist = dist ;
		}
	}
	
	Node spfa(int s){
		int[] dist = new int[n+1] ;
		Arrays.fill(dist , Integer.MAX_VALUE)  ;
		boolean[] inq = new boolean[n+1] ;
		Arrays.fill(inq , false) ;
		dist[s] = 0 ;
		inq[s] = true ;
		Queue<Integer> q = new LinkedList<Integer>() ;
		q.add(s) ;
		while(! q.isEmpty()){
			int u = q.poll() ;
			inq[u] = false ;
			for(int i = head[u] ; i != -1 ; i = e[i].next){
				int v = e[i].v ;
				if(dist[v] > dist[u] + 1){
					dist[v] = dist[u] + 1 ;
					if(! inq[v]){
						q.add(v) ;
						inq[v] = true ;
					}
				}
			}
		}
		Node res = new Node(-1 , -1) ;
		for(int i = 1 ; i <= n ; i++){
			if(res.dist < dist[i]){
				res.dist = dist[i] ;
			    res.u = i ;
			}
		}
		return res ;
	}
	
	void solve() {
		 n = in.nextInt() ;
		 m = in.nextInt() ;
		 Arrays.fill(head , -1) ;
		 for(int i = 1 ; i <= m ; i++)
			 add(in.nextInt() , in.nextInt()) ;
		 
		 out.println(spfa( spfa(1).u ).dist ) ; 
		 out.flush() ;
	}
	
}


class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = new StringTokenizer("") ;
	}
	
	private void eat(String s){
		tokenizer = new StringTokenizer(s) ;
	}
	
	public String nextLine(){
		try {
			return reader.readLine() ;
		} catch (Exception e) {
			return null ;
		}
	}
	
	public boolean hasNext(){
		while(!tokenizer.hasMoreTokens()){
			String s = nextLine() ;
			if(s == null) return false ;
			eat(s) ;
		}
		return true ;
	}
	
	public String next() {
		hasNext() ;
		return tokenizer.nextToken();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public BigInteger nextBigInteger() {
		return new BigInteger(next());
	}

}
