# 汎用性、再利用性を持たせたい
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
    #print startTable
    #print "\n"
    #print finishTable
    #print "\n"

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

  #p initTrain

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

  p initTrain.max

  #loop do
    #print start_table
    #print finish_table
    #break if start_table == [] || finish_table == []
    #if start_table[0] <= finish_table[0]
      #start_table.shift
      #puts max_train
    #else start_table [0] > finish_table[0]
      #max_train += 1
      #puts max_train
      #finish_table.shift
    #end
  #end
  
end

