class String
    def to_sec
        h, m, s = self.split(":").map(&:to_i)
        h * 60 * 60 + m * 60 + s
    end
end
loop do
    n = gets.to_i
    break if n == 0
    log = n.times.map{gets.split.map(&:to_sec)}
    h = Hash.new(0)
    log.each do |l|
        h[l[0]] += 1
        h[l[1]] -= 1
    end
    h = h.sort
    max = 0
    h.each_with_index do |t,i|
        next if i == 0
        h[i][1] += h[i-1][1]
        max = h[i][1] if h[i][1] > max
    end
    p max
end