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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EAntsInLeaves solver = new EAntsInLeaves();
        solver.solve(1, in, out);
        out.close();
    }

    static class EAntsInLeaves {
        ArrayList<Integer>[] tree;
        int[] par;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            tree = new ArrayList[n];
            par = new int[n];
            for (int i = 0; i < n; i++) tree[i] = new ArrayList<>();

            for (int i = 0; i < n - 1; i++) {
                int u = in.nextInt() - 1;
                int v = in.nextInt() - 1;
                tree[u].add(v);
                tree[v].add(u);
            }

            int ans = 0;
            for (int u : tree[0]) {
                ArrayList<node> leafs0 = new ArrayList<>();
                dfs(u, 0, leafs0, 0);
                Collections.sort(leafs0, new Comparator<node>() {

                    public int compare(node o1, node o2) {
                        return o1.lvl - o2.lvl;
                    }
                });

                int[] time = new int[leafs0.size()];
                time[0] = leafs0.get(0).lvl;
                for (int i = 1; i < leafs0.size(); i++) {
                    time[i] = Math.max(time[i - 1] + 1, leafs0.get(i).lvl);
                }
                ans = Math.max(time[leafs0.size() - 1], ans);
            }
            out.println(ans + 1);
        }

        void dfs(int u, int p, ArrayList<node> leafs0, int lvl) {
            par[u] = p;
            for (int v : tree[u]) {
                if (v == p) continue;
                dfs(v, u, leafs0, lvl + 1);
            }
            if (tree[u].size() == 1 && u != 0) {
                leafs0.add(new node(u, lvl));
            }
        }

        class node {
            int lvl;
            int n;

            node(int nn, int ll) {
                n = nn;
                lvl = ll;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

