import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix 

N,u,v = (int(x) for x in input().split())
mat = [[0] * N for i in range(N)]

for i in range(N-1):
  a,b = (int(x) for x in input().split())
  mat[a-1][b-1] = 1
  mat[b-1][a-1] = 1
  
matrix = np.array(mat)
dist = shortest_path(matrix,directed=False,unweighted=True).tolist()
num = 0
while(1):
  if u == v:
    break
  dic = dict(enumerate(dist[v-1]))
  for key,value in sorted(dic.items(),key=lambda x:x[1],reverse=True):
    if mat[u-1][key] != 0:
      u = key+1
      break
    
  if u == v:
    break
  dic = dict(enumerate(dist[u-1]))
  for key,value in sorted(dic.items(),key=lambda x:x[1]):
    if mat[v-1][key] != 0:
      v = key+1
      num += 1
      break
  if u == v:
    break
  

print(num)