def solve(edge)
  answer = 0
  edge.each do |key, value|
    answer = [answer, dfs(edge, key, Array.new)].max
  end
  answer
end

def dfs(edge, vertex, visited)
  visited[vertex] = true
  result = visited.count(true)
  edge[vertex].each do |v|
    next if visited[v]
    result = [result, dfs(edge, v, visited.dup)].max
  end
  result
end

until (n=gets.to_i)==0 do
  edge = Hash.new {|h,k|h[k]=Array.new}
  n.times do
    i, j = gets.split.map{|e|e.to_i-1}
    edge[i].push(j)
    edge[j].push(i)
  end
  p solve(edge)
end