object Main extends App {

  import scala.io.StdIn._

  val Array(w, h) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.split(' ').map(_.toLong) :+ 0L} :+ Array.tabulate(w + 1){_ ⇒ 0L}
  for (i ← (0 until h).reverse; j ← (0 until w).reverse) {
    state(i)(j) += state(i)(j + 1) + state(i + 1)(j) - state(i + 1)(j + 1)
  }
  val memo = Array.tabulate(h)({_ ⇒ Array.tabulate(w){_ ⇒ None: Option[Long]}})
  memo(h - 1)(w - 1) = if (((w + h) % 2 == 0 && state(h - 1)(w - 1) > 0) || ((w + h) % 2 == 1 && state(h - 1)(w - 1) < 0)) Some(state(h - 1)(w - 1)) else Some(-state(h - 1)(w - 1))
  val res = math.abs(solve(0, 0))
  println(res)
  def solve(x: Int, y: Int): Long = {
    if (x == w || y == h) 0
    else memo(y)(x) match {
      case Some(r) ⇒ r
      case None if (x + y) % 2 == 1 ⇒
        math.min(solve(x + 1, y) - state(y)(x) + state(y)(x + 1), solve(x, y + 1) + state(y)(x) - state(y + 1)(x)).also{r ⇒ memo(y)(x) = Some(r)}
      case None ⇒
        math.max(solve(x + 1, y) - state(y)(x) + state(y)(x + 1), solve(x, y + 1) + state(y)(x) - state(y + 1)(x)).also{r ⇒ memo(y)(x) = Some(r)}
    }
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}
