E = Hash.new{|h, k| h[k] = []}
N, u, v = gets.chomp.split(" ").map(&:to_i)
(N - 1).times{
  a, b = gets.chomp.split(" ").map(&:to_i)
  E[a] << b
  E[b] << a
}

q = [[v, 0]]
V = Array.new(N + 1, -1)
until(q.empty?) do
  a, d = q.shift
  V[a] = d
  E[a].each{|b| q.push([b, d + 1]) if V[b] == -1}
end

ans = [u, 0]
q = [[u, 0]]
until(q.empty?) do
  a, d = q.shift
  E[a].each{|b| (ans = [b, d + 1]; q.push([b, d + 1])) if V[b] > d + 1}
end

puts V[ans[0]] - ans[1] == 1 ? ans[1] : ans[1] + 1
