813_C. The Tag Game
Alice got tired of playing the tag game by the usual rules so she offered Bob a little modification to it. Now the game should be played on an undirected rooted tree of n vertices. Vertex 1 is the root of the tree.

Alice starts at vertex 1 and Bob starts at vertex x (x ≠ 1). The moves are made in turns, Bob goes first. In one move one can either stay at the current vertex or travel to the neighbouring one.

The game ends when Alice goes to the same vertex where Bob is standing. Alice wants to minimize the total number of moves and Bob wants to maximize it.

You should write a program which will determine how many moves will the game last.

Input

The first line contains two integer numbers n and x (2 ≤ n ≤ 2·105, 2 ≤ x ≤ n).

Each of the next n - 1 lines contains two integer numbers a and b (1 ≤ a, b ≤ n) — edges of the tree. It is guaranteed that the edges form a valid tree.

Output

Print the total number of moves Alice and Bob will make.

Examples

Input

4 3
1 2
2 3
2 4


Output

4


Input

5 2
1 2
2 3
3 4
2 5


Output

6

Note

In the first example the tree looks like this:

<image>

The red vertex is Alice's starting position, the blue one is Bob's. Bob will make the game run the longest by standing at the vertex 3 during all the game. So here are the moves:

B: stay at vertex 3

A: go to vertex 2

B: stay at vertex 3

A: go to vertex 3

In the second example the tree looks like this:

<image>

The moves in the optimal strategy are:

B: go to vertex 3

A: go to vertex 2

B: go to vertex 4

A: go to vertex 3

B: stay at vertex 4

A: go to vertex 4
```python
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from collections import defaultdict,deque
n,x=list(map(int,input().split()))
edge=defaultdict(list)
child=defaultdict(list)
for i in range(n-1):
    u,v=list(map(int,input().split()))
    edge[u].append(v)
    edge[v].append(u)
def bfsDistance(node):
    dist=[-1]*(n+1)
    vis[node]=1
    q=deque([node])
    dist[node]=0
    temp=0
    while q:
        cur=q.popleft()
        traverse.append(cur)
        for j in edge[cur]:
            if vis[j]==0:
                q.append(j)
                vis[j]=1
                dist[j]=dist[cur]+1
    return dist
def dfsFindLeaf(node):
    vis[node]=1
    stack=[node]
    while stack:
        cur=stack.pop()
        a=0
        for j in edge[cur]:
            if vis[j]==0:
                stack.append(j)
                if node==1:
                    child[cur].append(j)
                vis[j]=1
                a+=1
        if a==0:
            depth[cur]=0
vis=[0]*(n+1)
depth=[-1]*(n+1)
dfsFindLeaf(1)
vis=[0]*(n+1)
traverse=[]
arr1=bfsDistance(1)
vis=[0]*(n+1)
arr2=bfsDistance(x)
lis=[]
l=0
for i in range(1,n+1):
    if i!=1 and i!=x and arr1[i]+arr2[i]==arr1[x]:
        lis.append(i)
        l+=1
traverse.reverse()
for i in range(n):
    if depth[traverse[i]]==-1:
        maxi=0
        for j in child[traverse[i]]:
            maxi=max(depth[j]+1,maxi)
        depth[traverse[i]]=maxi
ans=2*(arr1[x]+depth[x])
for i in range(l):
    if arr1[lis[i]]>arr2[lis[i]]:
        temp=2*(arr1[lis[i]]+depth[lis[i]])
        ans=max(ans,temp)
print(ans)

        
```