Tree is a connected graph without cycles. A leaf of a tree is any vertex connected with exactly one other vertex.

You are given a tree with n vertices and a root in the vertex 1. There is an ant in each leaf of the tree. In one second some ants can simultaneously go to the parent vertex from the vertex they were in. No two ants can be in the same vertex simultaneously except for the root of the tree.

Find the minimal time required for all ants to be in the root of the tree. Note that at start the ants are only in the leaves of the tree.

Input

The first line contains integer n (2 ≤ n ≤ 5·105) — the number of vertices in the tree.

Each of the next n - 1 lines contains two integers xi, yi (1 ≤ xi, yi ≤ n) — the ends of the i-th edge. It is guaranteed that you are given the correct undirected tree.

Output

Print the only integer t — the minimal time required for all ants to be in the root of the tree.

Examples

Input

12
1 2
1 3
1 4
2 5
2 6
3 7
3 8
3 9
8 10
8 11
8 12


Output

6


Input

2
2 1


Output

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


public class Main {  
	static Scanner in;
	static PrintWriter out;
    public static void main(String[] args) { 
    	InputStream inputStream = System.in;  
    	OutputStream outputStream = System.out;  
        in = new Scanner(inputStream);  
        out = new PrintWriter(outputStream);  
        solve();
        out.close();
    }  
    

    static ArrayList<Integer> G[];  
    static pii que[];
    static int n, top;
    static int [] dep;
    static int [] dp;
    static void DFS(int u,int fa) {
    	boolean flag = false;
    	for(int v : G[u]) {
    		if(v == fa)  continue;
    		dep[v] = dep[u] + 1;
    		DFS(v, u);
    		flag = true;
    	}
    	if(flag == false) {
    		que[top ++] = new pii(dep[u], u);
    	}
    }
    static void solve() {  
    	n = in.nextInt();
    	que = new pii[n];
    	dp = new int[n];
    	dep = new int[n];
    	for(int i = 0; i < n; i ++) que[i] = new pii(0, 0);
    	G = new ArrayList[n];
    	for(int i = 0; i < n; i ++) G[i] = new ArrayList<Integer>();
    	for(int i = 0; i < n - 1; i ++) {
    		int x = in.nextInt() - 1;
    		int y = in.nextInt() - 1;
    		G[x].add(y);
    		G[y].add(x);
    	}
    	int ans = 0;
    	for(int v : G[0]){
    		top = 0;
    		dep[v] = 1;
    		DFS(v, 0);
    		Arrays.sort(que, 0, top, new Comp());
    		for(int i = 0; i < top; i ++) {
    			int u = que[i].Y;
    			dp[u] = dep[u];
    			if(i > 0) dp[u] = Math.max(dp[u], dp[que[i - 1].Y] + 1);
    			ans = Math.max(ans, dp[u]);
    		}
    	}
    	out.println(ans);
    	out.flush();
    }  
    
    
    
    
    
	  
	static class Comp implements Comparator {
		public int compare(Object x, Object y) {
			return ((pii)x).X - ((pii)y).X;
		}
	}
	    

    
    
    static class pii {
    	int X, Y;
    	pii(int X, int Y) {
    		this.X = X;
    		this.Y = Y;
    	}
    }

    

    static class Scanner {    
        BufferedReader br;    
        StringTokenizer st;    
                
        public Scanner(InputStream in) {  
            br = new BufferedReader(new InputStreamReader(in));  
            eat("");  
        }   
          
        private void eat(String s) {    
            st = new StringTokenizer(s);  
        }    
        
        public String nextLine() {    
            try {    
                return br.readLine();    
            } catch (IOException e) {    
                return null;    
            }    
        }    
        
        public boolean hasNext() {    
            while (!st.hasMoreTokens()) {    
                String s = nextLine();    
                if (s == null)    
                return false;    
                eat(s);    
            }    
            return true;    
        }    
        
        public String next() {    
            hasNext();    
            return st.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());    
        }    
            
            
    }    
}   