#include <bits/stdc++.h>

using namespace std;

// point
#define x first
#define y second
using pt = pair<int, int>;

const int N = 300300;
const int inf = 1e9;

int w, h, n;
pt a[N];
int t[N << 2];
int ad[N << 2];

void push(int v) {
   if (ad[v]) {
      t[v << 1] += ad[v];
      ad[v << 1] += ad[v];
      t[v << 1 | 1] += ad[v];
      ad[v << 1 | 1] += ad[v];
      ad[v] = 0;
   }
}

void build(int v, int l, int r) {
   t[v] = h - a[l].x;
   ad[v] = 0;
   if (l < r) {
      int md = (l + r) >> 1;
      build(v << 1, l, md);
      build(v << 1 | 1, md + 1, r);
   }
}

void add(int v, int l, int r, int L, int R, int val) {
   if (L <= l && r <= R) {
      t[v] += val;
      ad[v] += val;
      return;
   }
   push(v);
   int md = (l + r) >> 1;
   if (L <= md) {
      add(v << 1, l, md, L, R, val);
   }
   if (md < R) {
      add(v << 1 | 1, md + 1, r, L, R, val);
   }
   t[v] = max(t[v << 1], t[v << 1 | 1]);
}

int ans;
int ups[N];
int downs[N];

void solve() {
   sort(a + 1, a + n + 1);
   build(1, 0, n);
   int md = h >> 1; // cut line
   int uc = 0;
   int dc = 0;
   for (int i = 1; i <= n; ++i) {
      ans = max(ans, t[1] + a[i].x);
      if (a[i].y > md) {
         // modify ups
         add(1, 0, n, ups[uc], i - 1, a[i].y - h);
         for (; uc && a[ups[uc]].y > a[i].y; --uc) {
            add(1, 0, n, ups[uc - 1], ups[uc] - 1, a[i].y - a[ups[uc]].y);
         }
         ups[++uc] = i;
      } else {
         // modify downs
         add(1, 0, n, downs[dc], i - 1, -a[i].y);
         for (; dc && a[downs[dc]].y < a[i].y; --dc) {
            add(1, 0, n, downs[dc - 1], downs[dc] - 1, a[downs[dc]].y - a[i].y);
         }
         downs[++dc] = i;
      }
   }
   ans = max(ans, w + t[1]);
}

int main() {
   ios_base::sync_with_stdio(false);
   cin >> w >> h >> n;
   for (int i = 1; i <= n; ++i) {
      cin >> a[i].x >> a[i].y;
   }
   solve();
   for (int i = 1; i <= n; ++i) {
      swap(a[i].x, a[i].y);
   }
   swap(w, h);
   solve();
   cout << ans * 2 << "\n";
}

