#include using namespace std; using LL = long long int; #define incID(i, l, r) for(int i = (l) ; i < (r); ++i) #define incII(i, l, r) for(int i = (l) ; i <= (r); ++i) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i) #define decII(i, l, r) for(int i = (r) ; i >= (l); --i) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() auto setmin = [](auto & a, auto b) { return (b < a ? a = b, true : false); }; auto setmax = [](auto & a, auto b) { return (b > a ? a = b, true : false); }; auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); }; auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); }; auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); }; auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); }; auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; }; LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); } LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } #define bit(b, i) (((b) >> (i)) & 1) #define SI(v) static_cast(v.size()) #define RF(e, v) for(auto & e: v) #define until(e) while(! (e)) #define if_not(e) if(! (e)) #define ef else if #define UR assert(false) // ---- #define T0(T) T #define T1(T) vector #define T2(T) vector #define V0(v, T ...) v #define V1(v, T, n, ...) T1(T)(n, V0(v, T, __VA_ARGS__)) #define V2(v, T, n, ...) T2(T)(n, V1(v, T, __VA_ARGS__)) int main() { LL h, w, n; cin >> h >> w >> n; vector x(n), y(n); inc(i, n) { cin >> x[i] >> y[i]; } LL INF = 1e12; LL a = +INF, A = -INF; LL b = +INF, B = -INF; set parity; inc(i, n) { setmin(a, x[i] - y[i]); setmax(A, x[i] - y[i]); setmin(b, x[i] + y[i]); setmax(B, x[i] + y[i]); parity.insert(mo(x[i] + y[i], 2)); } if(SI(parity) == 2) { cout << 0 << endl; return 0; } using VPLL = vector>; auto v = V2(VPLL(), VPLL, 3, 3); inc(i, n) { int s = 1; if(x[i] - y[i] == a) { s = 0; } ef(x[i] - y[i] == A) { s = 2; } int t = 1; if(x[i] + y[i] == b) { t = 0; } ef(x[i] + y[i] == B) { t = 2; } if(SI(v[s][t]) == 0) { v[s][t].EB(x[i], y[i]); }; } set> done; auto ok = [&](LL X, LL Y) -> bool { bool exist = ! done.emplace(X, Y).SE; if(exist) { return false; } set dist; inc(i, 3) { inc(j, 3) { RF(e, v[i][j]) { dist.insert(abs(e.FI - X) + abs(e.SE - Y)); } } } return (SI(dist) == 1); }; auto xy = [](LL a, LL b) -> pair { return { (b + a) / 2, (b - a) / 2 }; }; vector X = { xy(a, B).FI, xy(A, b).FI }; vector Y = { xy(a, b).SE, xy(A, B).SE }; sort(ALL(X)); sort(ALL(Y)); LL ans = 0; LL xa = X[0] - 1, xb = h - X[1]; LL ya = Y[0] - 1, yb = w - Y[1]; if(ok(X[0] - 0, Y[0] - 0)) { ans += 1 * 1; } if(ok(X[0] - 1, Y[0] - 0)) { ans += xa * 1; } if(ok(X[0] - 0, Y[0] - 1)) { ans += 1 * ya; } if(ok(X[0] - 1, Y[0] - 1)) { ans += xa * ya; } if(ok(X[0] - 0, Y[1] + 0)) { ans += 1 * 1; } if(ok(X[0] - 1, Y[1] + 0)) { ans += xa * 1; } if(ok(X[0] - 0, Y[1] + 1)) { ans += 1 * yb; } if(ok(X[0] - 1, Y[1] + 1)) { ans += xa * yb; } if(ok(X[1] + 0, Y[0] - 0)) { ans += 1 * 1; } if(ok(X[1] + 1, Y[0] - 0)) { ans += xb * 1; } if(ok(X[1] + 0, Y[0] - 1)) { ans += 1 * ya; } if(ok(X[1] + 1, Y[0] - 1)) { ans += xb * ya; } if(ok(X[1] + 0, Y[1] + 0)) { ans += 1 * 1; } if(ok(X[1] + 1, Y[1] + 0)) { ans += xb * 1; } if(ok(X[1] + 0, Y[1] + 1)) { ans += 1 * yb; } if(ok(X[1] + 1, Y[1] + 1)) { ans += xb * yb; } if(ok(X[0] + 1, Y[0] + 1)) { ans += X[1] - X[0] - 1; } if(ok(X[0] + 1, Y[1] - 1)) { ans += X[1] - X[0] - 1; } cout << ans << endl; return 0; }