N,u,v=map(int,input().split())

def dijkstra(s,n,w,cost):
    d=[float("inf")]*n
    used=[False]*n
    d[s]=0
    while True:
        v = -1
        for i in range(n):
            if (not used[i]) and (v==-1):
               v=i
            elif (not used[i]) and d[i]<d[v]:
                v=i
        if v==-1:
               break
        used[v]=True
               
        for j in range(n):
               d[j]=min(d[j],d[v]+cost[v][j])
    return d

n=N
w=N-1
cost = [[float("inf") for i in range(n)] for i in range(n)] 
for i in range(w):
    x,y = map(int,input().split())
    x-=1
    y-=1
    cost[x][y] = 1
    cost[y][x] = 1

ni=dijkstra(u-1,n,w,cost)
ou=dijkstra(v-1,n,w,cost)

c=0
d=ni[v-1]
for i in range(N):
    if ni[i]<ou[i]:
        c=max(c,ni[i])

if c==0:
    if d%2==0:
        c=1
else:
    if d%2==0:
        c-=1
print(c)