import java.util.Scanner

object Main extends App { 
  val sc = new Scanner(System.in)
  val n, t  = sc.nextInt()
  val list = (for (i <- 0 until n) yield (sc.nextInt(), sc.nextInt())).toList

  type Move = (Int, Int) // (time, direction)

  def prep(ls:List[(Int, Int)], ac:List[Move]):List[Move] = {
    if (ls.isEmpty) ac.sortWith((a, b)=> (a._1 - b._1) match {
      case d if d > 0 => false
      case d if d < 0 => true
      case _ => a._2 < b._2  
    })
    else {
      val (l, r) = ls.head
      prep(ls.tail, (l,1)::(r,0)::ac)
    }
  }

  val moves = prep(list, Nil)

  def solver(l:List[Move], m:Int, ac:Int):Int = {
    if (l.isEmpty) m
    else {
      l.head match {
        case (_, 1) => solver(l.tail, m max ac+1, ac+1)
        case (_, _) => solver(l.tail, m, ac-1)
      }
    } 
  }

  println(solver(moves, 0, 0))
}

