while n = gets.to_i
  break if n == 0
  table = [0] * (3600 * 24)
  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
    table[p] += 1; table[q] -= 1
  end
  (1...3600 * 24).each{ |i| table[i] += table[i-1]}
  p table.max
end