while true
    n = gets.to_i
    if n == 0
        break
    end
    a=[]
    for i in 1..n
        str=gets.split(" ")
        s=(str[0][0..1].to_i*60 + str[0][3..4].to_i)*60+str[0][6..7].to_i
        t=(str[1][0..1].to_i*60 + str[1][3..4].to_i)*60+str[1][6..7].to_i
        a<<[s,1]
        a<<[t,0]
    end
    a.sort!
    waiting=0
    ret=0
    a.each{|it|
        if it[1]==1
            if waiting==0
                ret+=1
            else
                waiting-=1
            end
        elsif it[1]==0
            waiting+=1
        end
    }
    puts ret
end