class GraphBits
	def initialize(n)
		@n = n

		@bits = 1
		(n-1).times {
			@bits = (@bits << @n + 1) | 1
		}

		@ones = 1
		(n-1).times { @ones = (@ones << @n) | 1 }
		@select_mask = (0..@n-1).map{|i| @ones << i}

		@pos = {}
		x = 1
		@n.times {|i|
			@pos[x] = i
			x = (x << 1) | 1
		}
	end

	def add_edge(i, j)
		@bits |= (1 << i * @n + j)
		@select_mask[i] |= (@ones << j)
	end

	def node_size
		@n
	end

	def del_node(i)
		tmp = @bits & (@ones << i)
		@bits -= tmp
	end

	def select_node(i)
		@bits -= (@bits & @select_mask[i])
	end

	def deleted?(i)
		@bits[i * @n + i] == 0
	end

	def deg_zero?(i)
		tmp = subbits(i)
		tmp & (tmp - 1) == 0
	end

	def deg_one?(i)
		tmp = subbits(i)
		tmp &= (tmp - 1) 
		tmp & (tmp - 1) == 0
	end

	def subbits(i)
		(@bits >> i * @n) & ((1 << @n) - 1)
	end

	def opposite(i)
		tmp = subbits(i)
		tmp -= (1 << i)
		@pos[(tmp ^ (tmp - 1))]
	end
end

def search(g, i)
	return 1 if g.deg_zero?(i)
	max = 0
	g2 = g.dup
	g2.del_node(i)
	b = g.subbits(i)
	(0..g.node_size-1).each{|j|
		next if j == i || b[j] == 0
		m = search(g2, j)
		max = m if m > max
	}
	max + 1
end

loop {
	n = gets.to_i
	break if n == 0

	g = GraphBits.new(n)
	n.times {
		i, j = gets.split.map &:to_i
		g.add_edge(i-1, j-1)
		g.add_edge(j-1, i-1)
	}

	p (0..n-1).map{|i| search(g, i)}.max
}