
object Main extends App {

  import scala.io.StdIn._
  import scala.math.{max, abs}
  val Array(w, h, n) = readLine.trim.split(' ').map(_.toInt)
  val points = Array.tabulate(n){_ ⇒
    val Array(x, y) = readLine.trim.split(' ').map(_.toInt)
    Point(x, y)
  }
  println(
    (for (i ← 1 until n) yield {
      val Point(fromX, fromY) = points(i - 1)
      val Point(toX, toY) = points(i)
      if ((fromX - toX) * (fromY - toY) > 0) {
        max(abs(fromX - toX), abs(fromY - toY))
      }else {
        abs(fromX - toX) + abs(fromY - toY)
      }
    }).sum
  )
  case class Point(x: Int, y: Int)
}

