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
d = 0
q = [u]
VV = Array.new(N + 1, -1)
until(q.empty?) do
  nxt = []
  q.each{|a|
    ans = a
    VV[a] = d
    E[a].each{|b| nxt << b if V[b] > d + 1 && VV[b] == -1}
  }
  q = nxt
  d += 1 if not q.empty?
end

puts V.select.with_index{|a, idx| VV[idx] != -1}.max - 1
