import java.util.Scanner

object Main {
  def solve(sc: => Scanner): Int = {
    val N, D = sc.nextInt
    val A = Array.fill(N)((sc.nextInt, sc.nextInt))
    var now = 1
    var people = 0
    var ans = 0
    var prevTime = 0
    for (i <- 0 until N) {
      if (math.abs(now - A(i)._2) > A(i)._1 - prevTime) {
        return -1
      } else if (now - 1 + A(i)._2 - 1 <= A(i)._1 - prevTime) {
        ans += (now - 1) * people
        people = 0
        now = A(i)._2
        prevTime = A(i)._1
        people += 1
      } else {
        val time = math.abs(now - A(i)._2)
        ans += time * people
        people += 1
        if (people > D) {
          return -1
        }
        now = A(i)._2
        prevTime = A(i)._1
      }
    }
    ans + people * (now - 1)
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    println(solve(sc))
  }
}