n, u, v = [int(x) for x in input().split()]
adj     = [[] for _ in range(0, n + 1)]
vs      = [False] * (n + 1)

for i in range(1, n):
	a, b = [int(x) for x in input().split()]
	adj[a].append(b)
	adj[b].append(a)
	
def dfs(i, d, n):
	if i == d:
		return n
	
	vs[i] = True
	
	for j in adj[i]:
		r = dfs(j, d, n + 1)
		if r is not None:
			return r
		
	vs[i] = False
	
	return None
	
r = dfs(u, v, 0)

print(r)
