The birthday of puppy

0

0 votes
Medium, Medium
Problem

Alice used to live in her village with her fat brother puppy. Puppy’s bday was to be celebrated a few days forth. Alice wanted to celebrate puppy’s bday having all relatives from round the city onboard. But the city was a bit strange and there was a complication in all relatives getting together timely at Alice’s place. The roads of the city were in the form of a n-ary tree where alice used to live at the root position(node) and all the relatives used to live at the leaf nodes. There were some rules as to how relatives can reach the root node. Any parent node except the root node can be occupied by only one of the relatives at the children nodes at a time while they are on the way to Alice's place. The other relatives occupying the children nodes can wait till the time first one leaves the parent node. All the relatives who are staying at the children nodes of the root node are allowed to go to the root node simultaneously. Help Alice find the minimum time in which the relatives can come to her!

Note- The time for a relative to go to its parent node is one unit.

Note- The root node(Alice's and puppy's place) is represented by integer 1.

Input

The first line of test case contains an integer n (2 ≤ n ≤ 105) — the number of vertices in the tree.

Each of the next n - 1 lines contains two integers u,v (1 ≤ u, v ≤ 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 relatives to be in the party.

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

case 1: Considering each pair of integers as the nodes between which the edges are drawn we find that the relatives will be at the leaf nodes 4 and 3(considering 1 as the root node as said before).

at t=1: Relative 1(r1) at 4 reaches 2 and r2 stays at 3.

t=2: r1 reaches 3 and r2 reaches 2.

t=3: r1 reaches 1(alice's place) and r2 reaches at 3.

t=4: r2 also reaches at 1(alice's place).

Editor Image

?