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

public class Main {

    public static ArrayList<Integer>[] tree = null;
    public static boolean[] visited = null;

    public static void main(String... args) throws IOException {
        MyScanner in = new MyScanner(System.in);

        int leafCount = in.nextInt();
        tree = new ArrayList[leafCount + 1];
        visited = new boolean[leafCount + 1];

        for (int i = 0; i < leafCount + 1; i++) {
            tree[i] = new ArrayList<>();
        }

        for (int i = 0; i < leafCount - 1; i++) {
            int from = in.nextInt();
            int to = in.nextInt();

            tree[from].add(to);
            tree[to].add(from);
        }

        int result = 0;
        visited[1] = true;

        for (int child : tree[1]) {
            result = Math.max(result, visit(child));
        }

        System.out.println(result);
    }

    public static int visit(int node) {
        LinkedList<Pair> queue = new LinkedList<>();
        ArrayList<Integer> depths = new ArrayList<>();

        queue.addFirst(new Pair(node, 1));
        visited[node] = true;

        while (!queue.isEmpty()) {
            Pair next = queue.removeLast();

            if (tree[next.node].size() == 1) {
                depths.add(next.depth);
            } else {
                for (int child : tree[next.node]) {
                    if (!visited[child]) {
                        queue.addFirst(new Pair(child, next.depth + 1));
                        visited[child] = true;
                    }
                }
            }
        }

        int result = 0;

        for (int entry : depths) {
            result = Math.max(result + 1, entry);
        }

        return result;
    }

    public static class Pair {
        public int node, depth;

        public Pair(int node, int depth) {
            this.node = node;
            this.depth = depth;
        }
    }

    public static class MyScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public MyScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreElements()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            return tokenizer.nextToken();
        }

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

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