import scala.io.StdIn.readLine
import scala.util.control.Breaks._
import scala.collection.mutable.PriorityQueue
object Main{

  def main(args: Array[String]):Unit = {
    while(true){
      val n = readInt
      if(n == 0){ 
        break
      }
      val sq = new PriorityQueue[Int]()(Ordering.Int.reverse)
      val tq = new PriorityQueue[Int]()(Ordering.Int.reverse)
      var ans = 0
      var train = 0

      for(i <- 1 to n){
        val hmss = gethms() map (a => calcTime(a))
        sq += hmss(0)
        tq += hmss(1)
      }
      while( !(sq.isEmpty && tq.isEmpty) ){
        var s = 100000000
        var t = 100000000
        if( sq.length > 0 ){
          s = sq.head
        }
        if( tq.length > 0){
          t = tq.head
        }

        if( s >= t ){
          tq.dequeue()
          train -= 1
        }else if( t > s){
          sq.dequeue()
          train += 1
          ans = List(train,ans).max
        }
      }

      println(ans)
    }
  }

  def gethms(): Array[Array[Int]] = {
    readLine.split(" ") map ( a => a.split(":") map (b => b.toInt) )
  }

  def calcTime(hms: Array[Int]):Int = {
        hms(2) + 60*hms(1) + 3600*hms(0)
  }
}