n,u,v=gets.split.map(&:to_i)
nei=(0..n).map{[]}
(n-1).times{
  a,b=gets.split.map(&:to_i)
  nei[a] << b
  nei[b] << a
}

def dfs depth,height,parent,nei,ni,di
  depth[ni] = di
  height[ni] = nei[ni].map{|nii|
    if depth[nii]
      0
    else
      parent[nii] = ni
      1 + dfs(depth,height,parent,nei,nii,di+1)
    end
  }.max
end

depth = []
height = []
parent = []
dfs depth,height,parent,nei,v,0

#p depth,height,parent

half = u
cnt,m = (depth[u]-1).divmod(2)
cnt.times{
  half = parent[half]
}
p cnt+m+height[half]