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
}

ut = [0]
uq = [[u,0]]
vt = [0]
vq = [[v,0]]
n.times{
  un,ud = uq.pop
  ut[un] = ud
  nei[un].each{|ni|
    uq.push [ni,ud+1] unless ut[ni]
  }
  vn,vd = vq.pop
  vt[vn] = vd
  nei[vn].each{|ni|
    vq.push [ni,vd+1] unless vt[ni]
  }
}
p ut.zip(vt).select{|u,v|u<v}.max[1]-1