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.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
//     Test.testing();
        ConsoleIO io = new ConsoleIO();
        new Main(io).solve();
        io.flush();
    }
    ConsoleIO io;
    Main(ConsoleIO io) {
        this.io = io;
    }

    ArrayList<ArrayList<Integer>> gr1;
    boolean[] visit;
    //

    class Pair{
        public Pair(int a, int b){
            this.a = a;
            this.b = b;
        }
        public int a;
        public int b;
    }

    class Edge {
        public Edge(int c, int u,int v) {
            this.u = u;
            this.v = v;
            this.c = c;
        }
        public int u;
        public int v;
        public int c;
    }

    long MOD = 1_000_000_007;
    int n,m,k,fn;
    int[][] map;
    public void solve() {
        n = io.readInt();
        gr1 = new ArrayList<>();
        for(int i =0;i<n;i++)gr1.add(new ArrayList<>());
        for(int i = 0;i<n-1;i++){
            int[] l = io.readIntArray();
            int u = l[0]-1, v = l[1]-1;
            gr1.get(u).add(v);
            gr1.get(v).add(u);
        }
        level = new int[n];
        visit = new boolean[n];
        curr = new int[n];
        visit[0] = true;
        ArrayList<Integer> first = gr1.get(0);
        int res = 0;
        for(int i = 0;i<first.size();i++) {
            kk=0;
            dfs(first.get(i), 1);
            Integer[] all = new Integer[kk];
            for (int j = 0; j < kk; j++) all[j] = level[curr[j]];
            Arrays.sort(all);
            int max = 0;
            for (int j = 0; j < kk; j++) {
                if (all[j] <= max) max++;
                else max = all[j];
            }
            res = Math.max(res, max);
        }

        io.writeLine(res + "");
    }
    int[] level;
    int[] curr;
    int kk;
    void dfs(int node, int h) {
        level[node] = h;
        visit[node] = true;
        ArrayList<Integer> ch = gr1.get(node);
        boolean leaf = true;
        for (int i = 0; i < ch.size(); i++) {
            int v = ch.get(i);
            if (!visit[v]) {
                leaf = false;
                dfs(v, h + 1);
            }
        }
        if(leaf)curr[kk++] = node;
    }

    long gcd(long a, long b) {
        if (a < b) return gcd(b, a);
        if (b == 0) return a;
        return gcd(b, a % b);
    }
}

class ConsoleIO {
    BufferedReader br;
    PrintWriter out;
    public ConsoleIO(){br = new BufferedReader(new InputStreamReader(System.in));out = new PrintWriter(System.out);}
    public void flush(){this.out.close();}
    public void writeLine(String s) {this.out.println(s);}
    public void writeInt(int a) {this.out.print(a);this.out.print(' ');}
    public void writeWord(String s){
        this.out.print(s);
    }
    public String readLine() {try {return br.readLine();}catch (Exception ex){ return "";}}
    public long readLong() {
        return Long.parseLong(this.readLine());
    }
    public int readInt() {
        return Integer.parseInt(this.readLine().trim());
    }
    public long[] readLongArray() {
        String[]n=this.readLine().trim().split(" ");long[]r=new long[n.length];
        for(int i=0;i<n.length;i++)r[i]=Long.parseLong(n[i]);
        return r;
    }
    public int[] readIntArray() {
        String[]n=this.readLine().trim().split("\\s+");int[]r=new int[n.length];
        for(int i=0;i<n.length;i++)r[i]=Integer.parseInt(n[i]);
        return r;
    }
    public void writeIntArray(int[] a) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < a.length; i++) {if (i > 0) sb.append(' ');sb.append(a[i]);}
        this.writeLine(sb.toString());
    }
}


