Panda & His Bro

3.5

16 votes
Easy-Medium
Problem

Pandaland is a country & has N cities inside it. The cities are numbered from 1 to N. There are N-1 roads connecting these cities. We can reach a city from another city from a unique path(sequence of roads). Each road is of length 1 unit. Panda lives in a city called bambooland, but his bro, Rishi, due to some circumstances lives in a different city called thugland. Now, Panda wants to hangout with Rishi as they are bros. Unfortunately, they get to know that the distance between their cities is the maximum in Pandaland, i.e. no two cities in Pandaland have distance greater than that between bambooland and thugland. So, Panda needs to know the distance he has to travel to meet his bro Rishi. Help him out to find the distance between bambooland and thugland.

INPUT:

First line of Input contains an Integer N.

Next N-1 lines contains two space-separated integers X,Y denoting there exists a road between X & Y.

OUTPUT:

Print the answer in a Single line.

Constraints:

1<N<=10^5

1<=X,Y<=N

Problem Author: Rishi Kundu & Gaurav Sharma

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?