from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,ta,ao = inpl()
ta -= 1; ao -= 1
g = [[] for i in range(n)]
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
dist = [None] * n
dist[ao] = 0
def dfs(node):
    for v in g[node]:
        if dist[v] != None: continue
        dist[v] = dist[node] + 1
        dfs(v)
dfs(ao)
dist.sort()
print(dist[-1]-1)
