N, U, V = gets.split.map(&:to_i)
ABs = readlines.map{|l| l.split.map(&:to_i)}

@g = ABs.each_with_object(Hash.new{|h, k| h[k] = []}){|(a, b), h| h[a] << b; h[b] << a}
@d = Array.new(N + 1){Array.new(2)}

def dfs(u, v, d, i)
  @d[v][i] = d
  @g[v].each{|k| dfs(v, k, d + 1, i) unless k == u}
end

dfs(U, U, 0, 0)
dfs(V, V, 0, 1)
puts @d.drop(1).select{|u, v| u < v}.map(&:last).max - 1