if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
end

class Pos
  attr_reader :value
  
  def initialize(g)
    @used = Array.new(N, false)
    @value = Array.new(N, 0)
    @g = g
  end
  def dfs(i, cnt=0)
    return if @used[i]
    @used[i] = true
    @g[i].each do |j|
      dfs(j, cnt+1)
    end
    @value[i] = cnt
  end
end

def max(a, b)
  a > b ? a : b
end

N, U, V = gets.split.map(&:to_i)
AB = (N-1).times.map{gets.split.map(&:to_i)}

=begin
N = 10 ** 5
U, V =  1, N-1
ab=Array.new(N-1)
(N-1).times do |i|
  ab[i] = [i+1,i+2]
end
AB=ab
=end

g = Array.new(N){[]}
AB.each do |a, b|
  g[a-1] << b-1
  g[b-1] << a-1
end

takahashi = Pos.new(g)
aoki = Pos.new(g)
takahashi.dfs(U-1)
aoki.dfs(V-1)
ta = takahashi.value
ao = aoki.value

ans = 0
N.times do |i|
  if ao[i] - ta[i] > 0
    ans = max(ans, ao[i])
  end
end
p ans - 1