from queue import Queue

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

e = [[] for i in range(n)]

for i in range(n - 1):
  a, b = map(int, input().split())
  e[a - 1].append(b - 1)
  e[b - 1].append(a - 1)

q = Queue()
db = [-1 for i in range(n)]
q.put(v - 1)
db[v - 1] = 0
while True:
  if q.empty():
    break
  else:
    p = q.get()
    for _e in e[p]:
      if db[_e] < 0:
        q.put(_e)
        db[_e] = db[p] + 1

print(max(db) - 1)