def toSecond str
    arr = str.split(":").map(&:to_i)
    return arr[0] * 3600 + arr[1] * 60 + arr[2]
end

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

    arr = []
    n.times{arr << gets.chomp.split.map{|str| toSecond(str)}}
    arr.sort_by!{|a, b| [a, b]}
    
    yoyu, train, arr2 = 0, 0, []
    arr.each{|start, goal|
        before = arr2.length
        arr2.delete_if{|t| t <= start}
        yoyu += before - arr2.length
        if yoyu > 0
            yoyu -= 1
        else
            train += 1
        end
        arr2 << goal
    }
    puts train
end

