loop do
  n = gets.to_i
  break if n == 0
  a = n.times.map{gets.split.map{|l| l.split(":").map(&:to_i).inject{|s,i| s * 60 + i}}}.map{|a,b| [[a,1],[b-0.5,-1]]}.flatten(1)
  a = a.sort_by{|x,label| x}.map{|x,label| label}
  puts a.inject([0]){|s,label| s << (s.last + label)}.max
e