// 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 <iostream>
#include <list>
#include <queue>
#include <stack>
#include <tuple>
#include <valarray>
#include <vector>
// clang-format off
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":", ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream &o, tuple<T...> const &t){ o << "("; _ot<0>(o, t); o << ")"; return o; }
template<class T, class U> ostream & operator<<(ostream &o, pair<T, U> const &p) { o << "(" << p.first << ", " << p.second << ")"; return o; }
template < class T > ostream &operator<<(ostream &o, const stack<T> &a) { o << "{"; for(auto tmp = a; tmp.size(); tmp.pop()) o << (a.size() == tmp.size() ? "" : ", ") << tmp.top(); o << "}"; return o; }
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
#if !defined(DEBUG_LEFT)
#define DEBUG_LEFT "\e[1;36m"
#endif
#if !defined(DEBUG_RIGHT)
#define DEBUG_RIGHT ":\e[m"
#endif
#define dump(...) [&](){auto __debug_tap=make_tuple(__VA_ARGS__);DEBUG_OUT<<DEBUG_LEFT<<__LINE__ << DEBUG_RIGHT << " " <<#__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 &o, const T &a) { o << "{"; for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : ", ") << *ite; o << "}"; return o; }
#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 &o, const T &a) { for(auto ite = begin(a); ite != end(a); ++ite) o << (ite == begin(a) ? "" : " ") << *ite; return o; }
#endif
// clang-format on
// }}}


ll w, h;
int n;
const int N = 3e5;

// smin, smax {{{
// clang-format off
template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; }
template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; }
// clang-format on
// }}}

using P = pair<ll, ll>;
P p[N];

ll yc;

ll ans = 0;

constexpr ll inf = 1e18;
void dac(int l, int r) {
  int m = (l + r) >> 1;
  ll x1 = l-1 >= 0 ? p[l-1].first : 0;
  ll x2 = r < n ? p[r].first : w;

  if(r - l == 1) {
    smax(ans, h + x2 - p[l].first);
    smax(ans, h + p[l].first - x1);
    // dump(l, r, ans);
    return;
  }

  dac(l, m);
  dac(m, r);
  // x-dist, y1 < y2
  using Q = tuple<ll, ll, ll>;
  vector<Q> left;
  vector<Q> right;
  ll xc = p[m].first;
  // left {{{
  {
    ll y1 = 0, y2 = h;
    for(int i = m - 1; i >= l; i--) {
      ll x, y;
      tie(x, y) = p[i];
      assert(x < xc);
      if(y <= yc) {
        // lower
        left.emplace_back(xc - x, y1, y2);
        smax(y1, y);
      } else {
        // upper
        left.emplace_back(xc - x, y1, y2);
        smin(y2, y);
      }
    }
    left.emplace_back(xc - x1, y1, y2);
  }
  // }}}
  // right {{{
  {
    ll y1 = 0, y2 = h;
    for(int i = m; i < r; i++) {
      ll x, y;
      tie(x, y) = p[i];
      assert(x >= xc);
      if(y <= yc) {
        right.emplace_back(x - xc, y1, y2);
        smax(y1, y);
      } else {
        right.emplace_back(x - xc, y1, y2);
        smin(y2, y);
      }
    }
    right.emplace_back(x2 - xc, y1, y2);
  }
  // }}}
  reverse(begin(left), end(left));
  reverse(begin(right), end(right));

  // dump(left);
  // dump(right);

  int j1 = 0, j2 = 0; // j1 <= j2
  ll bias = 0;
  // value, index
  using R = tuple<ll, int>;
  // deque for slide minimazation
  deque<R> deq;
  ll bestRight = -inf;
  // {{{
  for(int i = 0; i < (int) left.size(); i++) {
    ll d, y1, y2;
    tie(d, y1, y2) = left[i];

    if(deq.size()) {
      int j;
      ll oldV;
      tie(oldV, j) = deq.front();
      ll D, Y1, Y2;
      tie(D, Y1, Y2) = right[j];
      ll V = D + min(y2, Y2) - max(y1, Y1);
      bias = V - (oldV + bias);
    } else bias = 0;

    while(j2 < right.size()) {
      ll D, Y1, Y2;
      tie(D, Y1, Y2) = right[j2];
      if(Y1 <= y1 && y2 <= Y2) break;
      // add
      ll v = D + min(y2, Y2) - max(y1, Y1);
      while(deq.size()) {
        ll V;
        tie(V, ignore) = deq.front();
        if(V + bias <= v); else break;
        deq.pop_front();
      }
      deq.emplace_front(v - bias, j2);
      j2++;
    }

    while(j1 + 1 <= j2 && j1 + 1 < (int) right.size()) {
      ll D, Y1, Y2;
      tie(D, Y1, Y2) = right[j1];
      if(y1 <= Y1 && Y2 <= y2); else break;
      // rem
      if(deq.size() && j1 == get<1>(deq.back())) deq.pop_back();
      smax(bestRight, Y2 - Y1 + D);
      j1++;
    }

    if(j2 < right.size()) smax(ans, y2 - y1 + d + get<0>(right[j2]));
    // dump(ans);
    smax(ans, bestRight + d);
    // dump(ans);
    if(deq.size()) smax(ans, get<0>(deq.back()) + bias + d);
    // dump(ans);
    // dump(d);
    // dump(i, j1, j2, bias);
    // dump(deq);
  }
  // }}}
  // dump(l, r, ans);
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> w >> h >> n;
  for(int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
  }
  // y = h / 2 を通る
  yc = h / 2;
  sort(p, p + n);
  dac(0, n);
  // dump(ans);
  // dump("------------");

  // x = w / 2 を通る
  swap(w, h);
  for(int i = 0; i < n; i++) swap(p[i].first, p[i].second);
  //
  yc = h / 2;
  sort(p, p + n);
  dac(0, n);
  cout << ans * 2 << endl;
  return 0;
}


Measured memory_bytes: 22808