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 {


    static class Node{
        public int index;
        public ArrayList<Node> nodes;
        public Node(int index){
            this.index = index;
            nodes = new ArrayList<Node>();
        }
        public boolean isChecked = false;

        public void connect(Node node){
            this.nodes.add(node);
        }

        public boolean isLeaf(){
            return nodes.size() == 1;
        }

//        @Override
//        public String toString(){
//            return Integer.toString(index);
//        }
    }

    static class AntQueue{
        public int max = 0;

        public void add(int n){
            if (max < n)
                max = n;
            else
                ++max;
        }
    }

    public static void connectHelper(int a, int b){
        Node nodeA = allNodes[a];
        if (nodeA == null){
            nodeA = new Node(a);
            allNodes[a] = nodeA;
        }
        Node nodeB = allNodes[b];
        if (nodeB == null){
            nodeB = new Node(b);
            allNodes[b] = nodeB;
        }
        nodeA.connect(nodeB);
        nodeB.connect(nodeA);
    }

    public static void searchBFS(Node node, AntQueue antQueue){
        LinkedList<Node> queue = new LinkedList<Node>();
        queue.add(node);
        int n = 1;
        int t = 1;
        int temp = 0;
        while (!queue.isEmpty()){
            Node iter = queue.removeFirst();
            iter.isChecked = true;
            if (iter.isLeaf())
                antQueue.add(n);
            for (int i = 0; i < iter.nodes.size(); ++i)
                if (!iter.nodes.get(i).isChecked)
                    queue.add(iter.nodes.get(i));
            --t;
            temp += iter.nodes.size() - 1;
            if (t == 0){
                t = temp;
                ++n;
                temp = 0;
            }
        }
    }

    public static int findInRoot(Node root){
        int result = 0;
        root.isChecked = true;
        for (Node node : root.nodes) {
            AntQueue q = new AntQueue();
            searchBFS(node, q);
            result = Math.max(result, q.max);
        }
        return result;
    }

    public static Node[] allNodes;

    public static void main(String[] args) {

        InputReader reader = new InputReader(System.in);
        //Scanner scanner = new Scanner(System.in);
        //int n = scanner.nextInt();
        int n = reader.nextInt();
        allNodes = new Node[n+1];

        for (int i = 1; i < n; ++i)
        {
            int a = reader.nextInt();
            int b = reader.nextInt();
            connectHelper(a, b);
        }

        if (allNodes[1] == null)
            System.out.println(0);
        else {
            Node r = allNodes[1];
            int res = findInRoot(r);
            System.out.println(res);
        }

    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}
