from collections import deque
n,u,v=map(int,input().split())
grid=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    grid[a].append(b)
    grid[b].append(a)
d=deque()
d.append(u-1)
dist_u=[-1 for _ in range(n)]
dist_u[u-1]=0
while d:
    s=d.popleft()
    for i in grid[s]:
        if dist_u[i]!=-1:
            continue
        dist_u[i]=dist_u[s]+1
        d.append(i)

d.append(v-1)
dist_v=[-1 for _ in range(n)]
dist_v[v-1]=0
while d:
    s=d.popleft()
    for i in grid[s]:
        if dist_v[i]!=-1:
            continue
        dist_v[i]=dist_v[s]+1
        d.append(i)
        

while True:
    if dist_u[dist_v.index(max(dist_v))]<dist_v[dist_v.index(max(dist_v))]:
        print(max(dist_v)-1)
        break
    else:
        dist_u.pop(dist_v.index(max(dist_v)))
        dist_v.pop(dist_v.index(max(dist_v)))