#submitができない、おそらく<<かsortのオーダーが大きい
def make_table(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
  
  startTable = []
  finishTable = []
  s = Array.new(oneDaySecond,0)
  (0..n-1).each do |i|
    start, finish = gets.chomp.split(" ").map(&:to_s)
    startTable << make_table(start)
    #startTable = startTable.sort
    finishTable << make_table(finish)
    #finishTable = finishTable.sort

    s[startTable[i]] += 1
    s[finishTable[i]] += -1
  end 
  (0...oneDaySecond-1).each do |j|
    s[j+1] += s[j]
  end
  p s.max
end


