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.*;
import java.util.*;

public class Main {
    public static void main (String[] args) throws IOException {
        Scan sc = new Scan();
        int n = sc.scanInt();
        int m = sc.scanInt();
        Solution sol = new Solution(n);
        while(m-- > 0){
            sol.ae(sc.scanInt(), sc.scanInt());
        }
        sol.solve();
    }
}

class Solution {
    ArrayList<Integer>[] al;
    int n;
    int[] in, ot;
    
    Solution(int n){
        this.n = n;
        al = new ArrayList[n+1];
        in = new int[n+1];
        ot = new int[n+1];
        for(int i = 1; i <= n; ++i)
            al[i] = new ArrayList<Integer>();
    }
    
    void ae(int a, int b){
        al[a].add(b);
        al[b].add(a);
    }
    
    int run1(int st, int par){
        int max = 0;
        for(int nbr : al[st]){
            if(nbr == par)
                continue;
            int temp = 1 + run1(nbr, st);
            max = Math.max(max, temp);
        }
        return in[st] = max;
    }
    
    void run2(int st, int par){
        int max1 = -1;
        int max2 = -1;
        for(int i : al[st]){
            if(i == par)
                continue;
            int curr = in[i];
            if(curr >= max1){
                max2 = max1;
                max1 = curr;
                continue;
            }
            if(curr >= max2){
                max2 = curr;
            }
        }
        
        for(int i : al[st]){
            if(i==par)
                continue;
            int curr = in[i];
            if(curr == max1){
                ot[i] = Math.max(2+max2, 1 + ot[st]);
            }
            else {
                ot[i] = Math.max(2+max1, 1 + ot[st]);
            }
            run2(i, st);
        }
    }
    
    void solve(){
        run1(1, -1);
        run2(1, -1);
        int max = 0;
        for(int i = 1; i <= n; ++i){
            max = Math.max(max, in[i]+ot[i]);
        }
        System.out.println(max);
    }
}

class Scan
{
    private byte[] buf=new byte[1024];
    private int index;
    private InputStream in;
    private int total;
    public Scan()
    {
        in=System.in;
    }
    public int scan()throws IOException
    {
        if(total<0)
        throw new InputMismatchException();
        if(index>=total)
        {
            index=0;
            total=in.read(buf);
            if(total<=0)
            return -1;
        }
        return buf[index++];
    }
    public int scanInt()throws IOException
    {
        int integer=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n))
        {
            if(n>='0'&&n<='9')
            {
                integer*=10;
                integer+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        return neg*integer;
    }
    public double scanDouble()throws IOException
    {
        double doub=0;
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        int neg=1;
        if(n=='-')
        {
            neg=-1;
            n=scan();
        }
        while(!isWhiteSpace(n)&&n!='.')
        {
            if(n>='0'&&n<='9')
            {
                doub*=10;
                doub+=n-'0';
                n=scan();
            }
            else throw new InputMismatchException();
        }
        if(n=='.')
        {
            n=scan();
            double temp=1;
            while(!isWhiteSpace(n))
            {
                if(n>='0'&&n<='9')
                {
                    temp/=10;
                    doub+=(n-'0')*temp;
                    n=scan();
                }
                else throw new InputMismatchException();
            }
        }
        return doub*neg;
    }
    public String scanString()throws IOException
    {
        StringBuilder sb=new StringBuilder();
        int n=scan();
        while(isWhiteSpace(n))
        n=scan();
        while(!isWhiteSpace(n))
        {
            sb.append((char)n);
            n=scan();
        }
        return sb.toString();
    }
    private boolean isWhiteSpace(int n)
    {
        if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
        return true;
        return false;
    }
}