problem

There is a light bulb at the grid point $ (x, y) $ that meets $ 1 \ leq x \ leq h, 1 \ leq y \ leq w $.

The power supply is installed at coordinates $ (i + 0.5, j + 0.5) (1 \ leq i <h, 1 \ leq j <w, i + j $ is even) (corrected at 14:21). Coordinates $ When the power supply installed at (i + 0.5, j + 0.5) $ is turned on, the coordinates $ (i, j), (i + 1, j), (i, j + 1), (i + 1) , j + 1) $ 4 $ light bulbs in $ glow.

If you have more than $ 1 $ connected to a power supply with a light bulb on $ (i, j) $, you get $ B_ {i, j} $ cleanliness. You have the total cleanliness. Also, if you turn on each power supply, it costs $ W $ for electricity per $ 1 $.

Turn on some power to maximize "total income-total electricity bill".



output

Output the maximum value of "total income-total electricity bill". Also, output a line break at the end.

Example

Input

4 4 10
100 100 100 100
100 100 100 100
1 100 100 1
1 1 1 1


Output

970
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

// #undef DEBUG
// #define DEBUG
// DEBUG {{{
#include <array>
#include <deque>
#include <list>
#include <ostream>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
template < int n, class... T >
typename enable_if< (n >= sizeof...(T)) >::type __output_tuple(ostream &,
    tuple< T... > const &) {}
template < int n, class... T >
typename enable_if< (n < sizeof...(T)) >::type __output_tuple(ostream &os,
    tuple< T... > const &t) {
  os << (n == 0 ? "" : ", ") << get< n >(t);
  __output_tuple< n + 1 >(os, t);
}
template < class... T >
ostream &operator<<(ostream &os, tuple< T... > const &t) {
  os << "(";
  __output_tuple< 0 >(os, t);
  os << ")";
  return os;
}
template < class T, class U >
ostream &operator<<(ostream &os, pair< T, U > const &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template < class T >
ostream &operator<<(ostream &os, const stack< T > &a) {
  os << "{";
  for(auto tmp = a; tmp.size(); tmp.pop())
    os << (a.size() == tmp.size() ? "" : ", ") << tmp.top();
  os << "}";
  return os;
}
template < class T, class Container, class Compare >
ostream &operator<<(ostream &os, priority_queue< T, Container, Compare > a) {
  os << "{ (top) ";
  while(a.size()) os << a.top() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
template < class T, class Container >
ostream &operator<<(ostream &os, queue< T, Container > a) {
  os << "{ ";
  while(a.size()) os << a.front() << (a.size() == 1 ? "" : ", "), a.pop();
  os << " }";
  return os;
}
#ifdef DEBUG
#if !defined(DEBUG_OUT)
#define DEBUG_OUT cerr
#endif
#define dump(...)                                                                \
  [&]() {                                                                        \
    auto __debug_tap = make_tuple(__VA_ARGS__);                                  \
    DEBUG_OUT << "[" << __LINE__ << "] " << #__VA_ARGS__ << " = " << __debug_tap \
    << endl;                                                           \
  }()
template < class T >
inline void dump2D(T &d, size_t sizey, size_t sizex) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << "\t";
    for(size_t j = 0; j < sizex; j++)
      DEBUG_OUT << d[i][j] << (j + 1 == sizex ? "" : "\t");
    DEBUG_OUT << endl;
  }
}
template < class T >
inline void dump1D(T &d, size_t sizey) {
  for(size_t i = 0; i < sizey; i++) {
    DEBUG_OUT << d[i] << (i + 1 == sizey ? "" : " ");
  }
  DEBUG_OUT << endl;
}
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type,
         class = typename enable_if< !is_same< T, string >::value >::type >
         ostream &operator<<(ostream &os, const T &a) {
           os << "{";
           for(auto ite = begin(a); ite != end(a); ++ite)
             os << (ite == begin(a) ? "" : ", ") << *ite;
           os << "}";
           return os;
         }
#else
#define dump(...) (42)
#define dump2D(...) (42)
#define dump1D(...) (42)
template < class T, class = typename iterator_traits< decltype(begin(T())) >::value_type,
         class = typename enable_if< !is_same< T, string >::value >::type >
         ostream &operator<<(ostream &os, const T &a) {
           for(auto ite = begin(a); ite != end(a); ++ite)
             os << (ite == begin(a) ? "" : " ") << *ite;
           return os;
         }
#endif
// }}}


// constructor(n, inf?) // be careful !
// addEdge(from, to, capacity, isDirected? = false)
//  - returns edgeID
// === build(s, t) - returns max flow (or inf) ===
// .edges[edgeID]
// === restoreMinCut(s) ===
// .isCut[edgeID]
// === --- ===
// inf * 2 < LL_MAX
/// --- Max Flow with Dinic {{{ ///
#include <algorithm>
#include <queue>
#include <vector>
struct Dinic {
  struct Edge {
    int from, to;
    ll cap, rev;
    int To(int i) const { return from == i ? to : from; }
    ll& Cap(int i) { return from == i ? cap : rev; }
    ll& Rev(int i) { return from == i ? rev : cap; }
  };

  int n;
  vector< Edge > edges;
  vector< vector< int > > g;
  ll inf;
  Dinic(int n, ll inf = 1e18) : n(n), g(n), inf(inf) {}
  int addEdge(int a, int b, ll cap, bool undirected = false) {
    edges.emplace_back((Edge){a, b, cap, undirected ? cap : 0});
    g[a].emplace_back(edges.size() - 1);
    g[b].emplace_back(edges.size() - 1);
    return edges.size() - 1;
  }
  vector< int > level;
  vector< size_t > itr;
  ll build(int s, int t) {
    level.resize(n);
    itr.resize(n);
    ll flow = 0, newflow;
    while(bfs(s), level[t] >= 0) {
      itr.assign(n, 0);
      while((newflow = dfs(s, t, inf)) > 0) {
        flow += newflow;
        if(flow >= inf) return inf;
      }
    }
    return flow;
  }
  vector< int > isCut;
  void restoreMinCut(int s) {
    isCut = vector< int >(edges.size());
    // bfs
    vector< int > used(n);
    queue< int > q;
    q.emplace(s);
    used[s] = 1;
    while(q.size()) {
      int i = q.front();
      q.pop();
      for(int idx : g[i]) {
        Edge& edge = edges[idx];
        if(!used[edge.To(i)] && edge.Cap(i) > 0) {
          q.emplace(edge.To(i));
          used[edge.To(i)] = 1;
        }
      }
    }
    for(size_t i = 0; i < edges.size(); i++) {
      if(used[edges[i].from] != used[edges[i].to]) isCut[i] = 1;
    }
  }

private:
  void bfs(int s) {
    fill(begin(level), end(level), -1);
    queue< int > q;
    q.emplace(s);
    level[s] = 0;
    while(q.size()) {
      int i = q.front();
      q.pop();
      for(int idx : g[i]) {
        Edge edge = edges[idx];
        if(level[edge.To(i)] < 0 && edge.Cap(i) > 0) {
          level[edge.To(i)] = level[i] + 1;
          q.emplace(edge.To(i));
        }
      }
    }
  }

  ll dfs(int v, int t, ll flow) {
    if(v == t) return flow;
    for(size_t& i = itr[v]; i < g[v].size(); ++i) {
      Edge& edge = edges[g[v][i]];
      if(edge.Cap(v) > 0 && level[edge.To(v)] > level[v]) {
        ll newflow = dfs(edge.To(v), t, min(flow, edge.Cap(v)));
        if(newflow == 0) continue;
        edge.Cap(v) -= newflow;
        edge.Rev(v) += newflow;
        return newflow;
      }
    }
    return 0;
  }
};
/// }}}--- ///

const ll inf = 1e18;

int h, w, c;

ll b[51][51];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> h >> w >> c;
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
    cin >> b[i][j];
  }
  int ww = (w + 1) / 2;
  int n = h * ww;
  Dinic flow(n + 2, inf);
  int s = n, t = n + 1;
  ll ans = 0;

  for(int i = 0; i < h-1; i++) for(int j = 0; j < w-1; j++) if(((i + j) & 1) == 0) {
    int u = i * ww + (j / 2);
    assert(u < n);
    dump(i, j, u);
    ll f = 0;
    f += b[i][j];
    f += b[i+1][j];
    f += b[i][j+1];
    f += b[i+1][j+1];
    ans += f;
    // y * w + x
    if(i & 1) {
      flow.addEdge(s, u, c);
      flow.addEdge(u, t, f);
      if(i-1 >= 0) {
        flow.addEdge((i-1) * ww + (j / 2), u, b[i][j]);
        flow.addEdge((i-1) * ww + (j / 2) + 1, u, b[i][j+1]);
      }
      if(i+1 < h) {
        flow.addEdge((i+1) * ww + (j / 2), u, b[i+1][j]);
        flow.addEdge((i+1) * ww + (j / 2) + 1, u, b[i+1][j+1]);
      }
    } else {
      flow.addEdge(s, u, f);
      flow.addEdge(u, t, c);
    }
  }

  auto v = flow.build(s, t);
  dump(ans, v);
  ans -= v;
  cout << ans << endl;
  return 0;
}

