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