while n = gets.to_i
    break if n == 0

    s = Array.new(86401, 0)
    n.times {
        start, finish = gets.chomp.split(" ").map {|a|
            t = a.split(":").map(&:to_i)
            t[0] * 3600 + t[1] * 60 + t[2]
        }
        s[start]+=1
        s[finish]-=1
    }
    (1..86400).each do |i|
        s[i] += s[i-1]
    end
    puts s.max
end

