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

dist = [100005]*(n+1)

q = []
q.append(v)
dist[v] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist[next] == 100005:
            q.append(next)
            dist[next] = dist[now] + 1

dist[0] = 0
print(max(dist)-1)
