from collections import deque

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

adj = [[] for i in range(100001)]

for i in range (0,n-1):
	u,v = map(int,input().split())
	adj[u].append(v)
	adj[v].append(u)

def bfs(u):
	vis = [False]*100001
	dist = [0]*100001
	Q = deque()
	vis[u]=True
	dist[u]=0
	Q.append(u)
	while Q:
		p = Q.popleft()
		for v in adj[p]:
			if vis[v]== False:
				vis[v]=True
				Q.append(v)
				dist[v]=1+dist[p]

	return dist

l1 = bfs(u)
l2 = bfs(v)
ans = []
for i in range(1,n+1):
	if l1[i] < l2[i]:
		ans.append(l2[i])

print(max(ans)-1)