while n = gets.to_i
  break if n == 0
  table = {}
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    p = sh * 3600 + sm * 60 + ss
    q = th * 3600 + tm * 60 + ts
    if table[p].nil? then table[p] = 1
    else table[p] += 1; end
    if table[q].nil? then table[q] = -1
    else table[q] -= 1; end
  end
  table = table.sort.transpose[1]
  (1...table.size).each{ |i| table[i] += table[i-1]}
  p table.max
end