def changeSecond(time)
  splitedTime = time.split(":").map(&:to_i)
  secondTime = 60*60*splitedTime[0] + 60*splitedTime[1] + splitedTime[2]
  return secondTime
end

oneDaySecond = 60*60*24
loop do
  n = gets.chomp.to_i
  break if n == 0

  s = Array.new(oneDaySecond,0)
  (0..n-1).each do |i|
    start, finish = gets.chomp.split(" ").map(&:to_s)
    start = changeSecond(start)
    finish = changeSecond(finish)
    s[start] += 1
    s[finish] += -1
  end 
  (0...oneDaySecond-1).each do |j|
    s[j+1] += s[j]
  end
  p s.max
end

