while(n=gets.to_i)>0
h=([0]*101).map{[]}
n.times{a,b=gets.split.map &:to_i;h[a]<<b;h[b]<<a}
ret=1
(1..100).each{|i|
  if h[i]!=[]
    u=[[i,0]]
    while u!=[]
      j,k=u[-1]
      while 1
        if !(l=h[j][k])
          u.pop
          break
        elsif u.assoc l
          ret = u.size if ret<u.size
          k+=1
        else
          u[-1][1]=k+1
          u<<[l,0]
          break
        end
      end
    end
  end
}

p ret
end