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.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Comparator;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Artem Gilmudinov
 */
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);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        int[][] g;
        PairInt[] pairs;
        boolean[] used;
        boolean[] leafs;
        int[] roots;
        int root;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            pairs = new PairInt[n];
            used = new boolean[n];
            leafs = new boolean[n];
            roots = new int[n];
            g = new int[n][];
            int[] cnt = new int[n];
            for (int i = 0; i < n; i++) {
                pairs[i] = new PairInt(i, 0);
            }
            PairInt[] edges = new PairInt[n - 1];
            for (int i = 0; i < n - 1; i++) {
                edges[i] = new PairInt(in.readInt() - 1, in.readInt() - 1);
                ++cnt[edges[i].x];
                ++cnt[edges[i].y];
            }
            for (int i = 0; i < n; i++) {
                g[i] = new int[cnt[i]];
            }
            for (PairInt edge : edges) {
                g[edge.x][--cnt[edge.x]] = edge.y;
                g[edge.y][--cnt[edge.y]] = edge.x;
            }

            used[0] = true;
            for (int u : g[0]) {
                root = u;
                dfs(u, 1);
            }
            Arrays.sort(pairs, new Comparator<PairInt>() {

                public int compare(PairInt o1, PairInt o2) {
                    return o1.y - o2.y;
                }
            });
            int[] min = new int[n];
            int ans = 0;
            for (int i = n - 1; i >= 1; i--) {
                PairInt pairInt = pairs[i];
                if (!leafs[pairInt.x]) {
                    continue;
                }
                ans = Math.max(ans, min[roots[pairInt.x]] + pairInt.y);
                ++min[roots[pairInt.x]];
            }

            out.println(ans);
        }

        public void dfs(int u, int h) {
            used[u] = true;
            pairs[u].y = h;
            roots[u] = root;
            int cnt = 0;
            for (int v : g[u]) {
                if (!used[v]) {
                    dfs(v, h + 1);
                    ++cnt;
                }
            }
            if (cnt == 0) {
                leafs[u] = true;
            }
        }

    }

    static class PairInt {
        public int x;
        public int y;

        public PairInt(int x, int y) {
            this.x = x;
            this.y = y;
        }


        public boolean equals(Object obj) {
            PairInt pairInt = (PairInt) obj;
            return pairInt.x == x && pairInt.y == y;
        }

        public String toString() {
            return x + " " + y;
        }

        public PairInt clone() {
            return new PairInt(x, y);
        }

    }

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

        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 readInt() {
            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;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}

