Torrent

Two computers start with a file in a tree; each minute, adjacent computers can copy in parallel subject to one copy per computer. Find the minimum minutes until all nodes have the file.

Medium7TreeBFSGreedyDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Mirko works at a data centre. Today he has to copy a file of 1 GiB to nn computers. The computers are numbered 1 through nn, and n1n-1 network cables each connect two computers directly. Between any two computers there is exactly one path, so the network is a tree.

Mirko placed the file by hand on computer aa and computer bb. He now writes the commands that move the file to every other computer. The file can be copied from computer xx to computer yy only when the two computers are connected by a cable, and one copy takes exactly one minute. At any moment a computer takes part in at most one copy, while any number of different pairs may copy at the same time. So once the copy from xx to yy finishes, during the next minute the file can be copied from xx to ww and from yy to zz at the same time.

Find the smallest number of minutes after which every computer holds the file.

In the first example every computer holds the file after two minutes.

Input

The first line contains the number of computers nn and the labels aa and bb of the two computers that already hold the file. (2n2000002 \le n \le 200000, 1a,bn1 \le a, b \le n, aba \ne b)

Each of the next n1n-1 lines contains the labels xx and yy of two computers connected directly by a cable. (1x,yn1 \le x, y \le n, xyx \ne y)

The network is always a tree.

Output

Print the smallest number of minutes after which every computer holds the file.

Hint

The trees of the second and the third example.