n,u,v = (int(num) for num in input().split())
u -= 1
v -= 1
adj = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = (int(num)-1 for num in input().split())
    adj[a].append(b)
    adj[b].append(a)
    
visited = [0] * n
d = [-1] * n
q = []
q.append(u)
visited[u] = 1
d[u] = 0
while q != []:
    vt = q.pop(0)
    dt = d[vt]
    for vnext in adj[vt]:
        if visited[vnext] == 0:
            visited[vnext] = 1
            d[vnext] = dt + 1
            q.append(vnext)
            
visited = [0] * n
e = [-1] * n
q = []
q.append(v)
visited[v] = 1
e[v] = 0
while q != []:
    vt = q.pop(0)
    dt = e[vt]
    for vnext in adj[vt]:
        if visited[vnext] == 0:
            visited[vnext] = 1
            e[vnext] = dt + 1
            q.append(vnext)

ans = 0
for i in range(n):
    dd = d[i]
    de = e[i]
    yoyu = de - dd
    if yoyu > 0:
        ans = max(ans, dd + yoyu // 2)
print(ans)