
fun main(args:Array<String>):Unit{
    while(true){
        val n = readLine()!!.toInt()
        if (n == 0) return
        var max = 0
        var current = 0
        Array(n){
            val arg = readLine()!!.split(' ')
            val (sh, sm, ss) = arg.first().split(':').map(String::toInt)
            val (th, tm, ts) = arg.last().split(':').map(String::toInt)
            listOf(Time(sh, sm, ss, true), Time(th,tm,ts, false))
        }.flatMap { it }.sortedWith(compareBy(Time::hour, Time::minute, Time::second, Time::isStart)).forEach{
            if (it.isStart)
                ++current
            else
                --current
            if (current > max)
                max = current
        }
        println(max)
    }
}
data class Time(val hour:Int, val minute:Int, val second:Int, val isStart:Boolean)
