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 = []
  initTrain = 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

    initTrain[startTable[i]] += 1
    initTrain[finishTable[i]] += -1
  end 

  (0...oneDaySecond-1).each do |j|
    #p initTrain[j+1]
    initTrain[j+1] += initTrain[j]
    #p "#{j}の時は#{initTrain[j]}と#{initTrain[j+1]}"
  end

  p initTrain.max
  
end

