import scala.annotation.tailrec
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val t = readLong
  val n = readInt
  val events = Array.tabulate(n){_ ⇒
    val Array(s, t) = readLine.trim.split(' ').map(_.toLong)
    Event(s, t)
  }
  val eventTimeSum = BigInt(0) +: events.map(e ⇒ BigInt(e.end - e.start))
  for (i ← eventTimeSum.indices.tail) eventTimeSum(i) += eventTimeSum(i - 1)
  var max = BigInt(0)
  for ((event, i) ← events.zipWithIndex){
    val until = lowerBound(events, event.start + t)
    if (until < n){
      if (events(until).start < event.start + t) {
        if (max < eventTimeSum(until) - eventTimeSum(i) + event.start + t - events(until).start) max = eventTimeSum(until) - eventTimeSum(i) + event.start + t - events(until).start
      }else {
        if (max < eventTimeSum(until) - eventTimeSum(i)) max = eventTimeSum(until) - eventTimeSum(i)
      }
    } else if (until == n && max < eventTimeSum(until) - eventTimeSum(i)) max = eventTimeSum(until) - eventTimeSum(i)
  }
  println(max)

  def lowerBound(array: Array[Event], time: Long): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (array(mid).end < time){
        left = mid + 1
      } else {
        right = mid
      }
    }
    right
  }
  case class Event(start: Long, end: Long)
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline
    def let[A](func: T ⇒ A): A = func(value)
  }
}

