n,u,v = map(int,input().split())
inf = 10 ** 6
u -= 1
v -= 1
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
seen = [0 for _ in range(n)]
rank = [0 for _ in range(n)]
seen[v] = 1
now = [v]
pst = [[] for _ in range(n)]
pre = [inf for _ in range(n)]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] = 1
        rank[y] = rank[x] + 1
        pst[x].append(y)
        pre[y] = x
        now.append(y)
print(rank)
r = rank[u]
if r % 2 == 0:
  m = r//2 + 1
  M = u
  for _ in range(r-m):
    M = pre[M]
  now = [M]
  while now != []:
    last = now
    now = []
    for x in last:
      for y in pst[x]:
        now.append(y)
  ans = rank[last[0]] - m + r - m + 1
  #print(r,m,M,rank[last[0]],last[0])
  #print(0,ans)
else:
  m = r//2 + 1
  M = u
  for _ in range(r-m):
    M = pre[M]
  now = [M]
  while now != []:
    last = now
    now = []
    for x in last:
      for y in pst[x]:
        now.append(y)
  ans = rank[last[0]] - m + r - m
  #print(r,m,M,rank[last[0]],last[0])
  #print(1,ans)
print(ans)