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
/* "Why do we fall? So we can learn to pick ourselves up." */

import java.util.*;
import java.io.*;
import java.math.*;

public class Graph

{ 
	 static FastReader sc=new FastReader(); 
	 static int mod=(int)Math.pow(10, 9)+7;
	 static int a,b,c;
	 static boolean ans;
		  public static void main(String[] args) 
    {
			   PrintWriter out=new PrintWriter(System.out);
			  StringBuffer sb=new StringBuffer("");
			  
			  int ttt=1;
			     //ttt =i(); 
		        outer :while (ttt-- > 0) 
				{
		        	int n=i()+1;
		        	int m=i();
		        	ArrayList<Integer> A[]=new ArrayList[n];
		        	//HashMap<Integer,Integer> M[]=new HashMap[n];
		        	for(int i=0;i<A.length;i++) {
		        		A[i]=new ArrayList<Integer>();
		        		//M[i]=new HashMap<Integer, Integer>();
		        	}
		        	
		        	for(int i=0;i<m;i++) {
		        		int a=i();
		        		int b=i();
		        		A[a].add(b);
		        		A[b].add(a);
		        	}
		        	int res=0;
		        	boolean v[]=new boolean[n];
		        	int d[]=new int[n];
		        	bfs(A, v, 1, d);
		        	int min=Integer.MIN_VALUE;
		        	int no=-1;
		        	for(int i=1;i<n;i++) {
		        		if(d[i]>min) {
		        			min=d[i];
		        			no=i;
		        		}
		        	}
		        	Arrays.fill(v, false);
		        	Arrays.fill(d, 0);
		        	bfs(A, v, no, d);
		        	min=Integer.MIN_VALUE;
		        	for(int i : d)
		        		if(i>min)
		        			min=i;
		        	System.out.println(min);
		        	
		        	
				}
				
			     out.close();
		    	//System.out.println(sb.toString());
		        	
    }
			  static void dfs(ArrayList<Integer>[] A, boolean[] v, int i) {
				  v[i]=true;
				  if(A[i].size()!=2)
					  ans=false;
				  int t=0;
				  for(int c: A[i]) {
					  if(!v[c]) {
						  t++;
					  
						  dfs(A, v, c);
				  }
				  }
				  if(t==2)
					  a++;
				  else if(t==0)
					  c++;
				  else if(t>2)
					  b++;
						  
			  }
		  
		  
		  
		  
		  private static void bfs(ArrayList<Integer>[] A, boolean[] v, int i, int[] d) {
				Queue<Integer> q=new LinkedList<Integer>();
				q.add(i);
				v[i]=true;
				d[i]=0;
				while(!q.isEmpty()) {
					int s=q.poll();
					for(int child : A[s]) {
						if(!v[child]) {
							q.add(child);
							v[child]=true;
							d[child]=d[s]+1;
						}
					}
				}
				
			
		}



		static void bfs(ArrayList<Integer>[] A, int i, boolean[] v, HashMap<Integer,Integer> map,int d[],int dest){
			  v[i]=true;
			  Queue<Integer> q=new LinkedList<Integer>();
			  q.add(i);
			  d[i]=0;
			  while(!q.isEmpty()) {
				  int f=q.poll();
				  if(f==dest)
					  return;
				  for(int child : A[f]) {
					  if(!v[child]) {
						  q.add(child);
						  d[child]=d[f]+1;
						  v[child]=true;
						  map.put(child, f);
					  }
				  }
			  }
		  }
		  
		  









private static ArrayList<Integer> dfs(ArrayList<Integer>[] A, int i, boolean[] v, int par) {
v[i]=true;
for(int child : A[i]) {
	if(!v[child]) {
		ArrayList<Integer> l=dfs(A, child, v, i);
		if(l!=null) {
			if(l.get(0)!=l.get(l.size()-1))
			l.add(i);
			return l;
		}
	}
	else {
		if(child!=par && par!=0) {
			ArrayList<Integer> l=new ArrayList<Integer>();
			l.add(child);
			l.add(i);
			return l;
		}
	}
}
	return null;
		}











static int[] input(int n) {
	int A[]=new int[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextInt();
	   }
	   return A;
   }
static long[] inputL(int n) {
	long A[]=new long[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextLong();
	   }
	   return A;
   }
static String[] inputS(int n) {
	String A[]=new String[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.next();
	   }
	   return A;
   }
static long sum(int A[]) {
	long sum=0;
	for(int i : A) {
		sum+=i;
	}
	return sum;
}

static void input(int A[],int B[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
		   B[i]=sc.nextInt();
	   }
}
static int[][] input(int n,int m){
	int A[][]=new int[n][m];
	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			A[i][j]=i();
		}
	}
	return A;
}
static int max(int A[]) {
	int max=Integer.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static int min(int A[]) {
	int min=Integer.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long max(long A[]) {
	long max=Long.MIN_VALUE;
	for(int i=0;i<A.length;i++) {
		max=Math.max(max, A[i]);
	}
	return max;
}
static long min(long A[]) {
	long min=Long.MAX_VALUE;
	for(int i=0;i<A.length;i++) {
		min=Math.min(min, A[i]);
	}
	return min;
}
static long mod(long x) {
	 int mod=1000000007;
	  return ((x%mod + mod)%mod);
}

     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }  
     static void sort(int[] A){
        int n = A.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = A[i];
            int randomPos = i + rnd.nextInt(n-i);
            A[i] = A[randomPos];
            A[randomPos] = tmp;
        }
        Arrays.sort(A);
     }
     static void sort(long[] A){
	        int n = A.length;
	        Random rnd = new Random();
	        for(int i=0; i<n; ++i){
	            long tmp = A[i];
	            int randomPos = i + rnd.nextInt(n-i);
	            A[i] = A[randomPos];
	            A[randomPos] = tmp;
	        }
	        Arrays.sort(A);
	     }
  static String sort(String s) {
 	 Character ch[]=new Character[s.length()];
 	 for(int i=0;i<s.length();i++) {
 		 ch[i]=s.charAt(i);
 	 }
 	 Arrays.sort(ch);
 	 StringBuffer st=new StringBuffer("");
 	 for(int i=0;i<s.length();i++) {
 		 st.append(ch[i]);
 	 }
 	 return st.toString();
  }
     static boolean prime(int n) 
	    { 
	        if (n <= 1) 
	            return false; 
	        if (n <= 3) 
	            return true; 
	        if (n % 2 == 0 || n % 3 == 0) 
	            return false; 
	        double sq=Math.sqrt(n);
	  
	        for (int i = 5; i <= sq; i = i + 6) 
	            if (n % i == 0 || n % (i + 2) == 0) 
	                return false; 
	        return true; 
	    } 
     static boolean prime(long n) 
	    { 
	        if (n <= 1) 
	            return false; 
	        if (n <= 3) 
	            return true; 
	        if (n % 2 == 0 || n % 3 == 0) 
	            return false; 
	        double sq=Math.sqrt(n);
	  
	        for (int i = 5; i <= sq; i = i + 6) 
	            if (n % i == 0 || n % (i + 2) == 0) 
	                return false; 
	        return true; 
	    } 
     static int gcd(int a, int b) 
     { 
         if (a == 0) 
             return b; 
         return gcd(b % a, a); 
     } 
     static long gcd(long a, long b) 
     { 
         if (a == 0) 
             return b; 
         return gcd(b % a, a); 
     } 
     static class Pair //implements Comparable<Pair>
     {
    	 int x;
    	 int y;
    	 Pair(int x,int y){
    		 this.x=x;
    		 this.y=y;
    	 }
     }
        
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 



