def resolve():
	
	n, u, v = map(int, input().split())
	u -= 1
	v -= 1
	adj = [[] for i in range(n)]
	for i in range(n-1):
		a, b = map(int, input().split())
		adj[a-1].append(b-1)
		adj[b-1].append(a-1)
		
	dist_t = [0 for i in range(n)]
	dist_a = [0 for i in range(n)]
	def dfs_t(now, prv, cnt):
#		print(f"{now=}, {prv=}, {cnt}")
		for next in adj[now]:
			if next == prv:
				dist_t[now] = cnt
				continue
			dfs_t(next, now, cnt+1)
	def dfs_a(now, prv, cnt):
#		print(f"{now=}, {prv=}, {cnt}")
		for next in adj[now]:
			if next == prv:
				dist_a[now] = cnt
				continue
			dfs_a(next, now, cnt+1)
#	print(f"{adj=}\n")
	dfs_t(u, u, 0)
	dfs_a(v, v, 0)
	
	tmp = [dt for da, dt in zip(dist_t, dist_a) if dt > da]
	print(max(tmp) -1)
	
resolve()