while n = gets.to_i
  break if n == 0
  table = []
  set = []
  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
    set << p; set << q; table << [p, q]
  end
  set = set.uniq.sort
  t = [0] * set.size
  table.each do |p, q|
    for i in (set.index(p)...set.index(q))
      t[i] += 1
    end
  end
  p t.max
end