while n = gets.to_i
  break if n == 0
  tr = {}
  n.times do
    sh, sm, ss, th, tm, ts = gets.split(/\s|:/).map(&:to_i)
    s = sh * 3600 + sm * 60 + ss
    tr[s] = th * 3600 + tm * 60 + ts
  end
  tr = tr.sort
  max = 0
  on_rail = []
  tr.each do |s, t|
    max = [max, on_rail.size].max
    while !on_rail.empty? && (time = on_rail.min{|a, b| a <=> b}) <= s
      on_rail.delete(time)
    end
    on_rail << t
  end
  p max
end