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 E implements Runnable {
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}
	
	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		System.err.println("Go!");

		int n = fs.nextInt();
		int[] deg = new int[n];
		int[] us = new int[n-1], vs = new int[n-1];
		int[][] adj = new int[n][];
		for(int i = 0; i < n-1; i++) {
			int u = fs.nextInt()-1;
			int v = fs.nextInt()-1;
			deg[u]++; deg[v]++;
			us[i] = u; vs[i] = v;
		}
		for(int i = 0; i < n; i++) adj[i] = new int[deg[i]];
		for(int i = 0; i < n-1; i++) {
			int u = us[i], v = vs[i];
			adj[u][--deg[u]] = v;
			adj[v][--deg[v]] = u;
		}
		int res = 0;
		int[] list = new int[n], depth = new int[n];
		Arrays.fill(depth, -1); depth[0] = 0;
		for(int k : adj[0]) {
			//since everyone can jump to the root simultaneously
			//we should get everyone up asap.
			
			ArrayDeque<Integer> dq = new ArrayDeque<>();
			dq.add(k); depth[k] = 1;
			int ptr = 0;
			while(!dq.isEmpty()) {
				int u = dq.pollFirst();
				boolean leaf = true;
				for(int v : adj[u]) if(depth[v] == -1) {
					depth[v] = depth[u]+1; leaf = false;
					dq.add(v);
				}
				if(leaf) {
					list[ptr++] = depth[u]-1;
				}
			}
			
			Arrays.sort(list, 0, ptr);
			for(int i = 0; i < ptr; i++) {
				if(i > 0) list[i] = Math.max(list[i], list[i-1] + 1);
			}
			res = Math.max(res, 1 + list[ptr-1]);
			
		}
		out.println(res);
		out.close();
	}
	
	class FastScanner {
		public int BS = 1<<16;
		public char NC = (char)0;
		byte[] buf = new byte[BS];
		int bId = 0, size = 0;
		char c = NC;
		double num = 1;
		BufferedInputStream in;

		public FastScanner() {
			in = new BufferedInputStream(System.in, BS);
		}

		public FastScanner(String s) throws FileNotFoundException {
			in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
		}

		public char nextChar(){
			while(bId==size) {
				try {
					size = in.read(buf);
				}catch(Exception e) {
					return NC;
				}                
				if(size==-1)return NC;
				bId=0;
			}
			return (char)buf[bId++];
		}

		public int nextInt() {
			return (int)nextLong();
		}

		public long nextLong() {
			num=1;
			boolean neg = false;
			if(c==NC)c=nextChar();
			for(;(c<'0' || c>'9'); c = nextChar()) {
				if(c=='-')neg=true;
			}
			long res = 0;
			for(; c>='0' && c <='9'; c=nextChar()) {
				res = (res<<3)+(res<<1)+c-'0';
				num*=10;
			}
			return neg?-res:res;
		}

		public double nextDouble() {
			double cur = nextLong();
			return c!='.' ? cur:cur+nextLong()/num;
		}

		public String next() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c>32) {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public String nextLine() {
			StringBuilder res = new StringBuilder();
			while(c<=32)c=nextChar();
			while(c!='\n') {
				res.append(c);
				c=nextChar();
			}
			return res.toString();
		}

		public boolean hasNext() {
			if(c>32)return true;
			while(true) {
				c=nextChar();
				if(c==NC)return false;
				else if(c>32)return true;
			}
		}
		
		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for(int i = 0; i < n; i++) res[i] = nextInt();
			return res;
		}
		
	}

	
}