#include<bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const int64 infll = (1LL << 61) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

using pi = pair< int, int >;

int W, H, N, L;
vector< pi > P;


// H/2を通る
template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = f(seg[k], x);
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};

auto f = [](int a, int b) { return max(a, b); };

int rec(int l, int r) {
  if(l + 1 >= r) return 0;
  int mid = (l + r) / 2;
  int ret = max(rec(l, mid), rec(mid, r));


  int UY = 0, DY = H;
  vector< pair< pi, pi > > ask;
  vector< int > xs;
  for(int i = mid - 1; i >= l; i--) {
    xs.emplace_back(DY);
    ask.emplace_back(pi(P[i].first, 0), pi(UY, DY));
    if(P[i].second < L) chmax(UY, P[i].second);
    else chmin(DY, P[i].second);
  }
  UY = 0, DY = H;
  for(int i = mid; i < r; i++) {
    xs.emplace_back(DY);
    ask.emplace_back(pi(P[i].first, 1), pi(UY, DY));
    if(P[i].second < L) chmax(UY, P[i].second);
    else chmin(DY, P[i].second);
  }

  sort(ask.begin(), ask.end(), [&](auto p, auto q) {
    return p.second.first < q.second.first;
  });
  sort(begin(xs), end(xs));
  xs.erase(unique(begin(xs), end(xs)), end(xs));
  // これ逆もやらないといけなくないか
  {
    SegmentTree< int > seg1(xs.size(), f, -inf), seg2(xs.size(), f, -inf);
    for(auto &p : ask) {
      int pos = lower_bound(begin(xs), end(xs), p.second.second) - begin(xs);
      int64 subret = -infll;
      if(p.first.second) {
        chmax(subret, seg1.query(pos, xs.size()) + p.second.second);
        chmax(subret, seg2.query(0, pos));
        chmax(ret, subret + p.first.first - p.second.first);
      } else {
        seg1.update(pos, -p.first.first);
        seg2.update(pos, -p.first.first + p.second.second);
      }
    }
  }

  {
    SegmentTree< int > seg1(xs.size(), f, -inf), seg2(xs.size(), f, -inf);
    for(auto &p : ask) {
      int pos = lower_bound(begin(xs), end(xs), p.second.second) - begin(xs);
      int64 subret = -infll;
      if(p.first.second) {
        seg1.update(pos, p.first.first);
        seg2.update(pos, p.first.first + p.second.second);
      } else {
        chmax(subret, seg1.query(pos, xs.size()) + p.second.second);
        chmax(subret, seg2.query(0, pos));
        chmax(ret, subret - p.first.first - p.second.first);
      }
    }
  }


  return ret;
}

int main() {
  cin >> W >> H >> N;
  P.resize(N);
  for(auto &p : P) {
    cin >> p.first >> p.second;
  }
  P.emplace_back(0, 0);
  P.emplace_back(W, H);
  sort(begin(P), end(P));
  P.erase(unique(begin(P), end(P)), end(P));
  N = (int) P.size();
  L = H / 2;
  int ret = rec(0, N);
  swap(W, H);
  for(auto &p : P) swap(p.first, p.second);
  sort(begin(P), end(P));
  L = H / 2;
  cout << max(ret, rec(0, N)) * 2 << endl;
}


Measured memory_bytes: 20672