#include <cassert>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <utility>
static const int MAXN = 3e5 + 4;
 
int w, h, n;
int x[MAXN], y[MAXN];
int x_mapped[MAXN], y_mapped[MAXN];
 
inline void discretize(int n, int *arr, int *mapped)
{
    static std::pair<int, int> p[MAXN];
    for (int i = 0; i < n; ++i) p[i] = std::make_pair(arr[i], i);
    std::sort(p, p + n);
    for (int i = 0; i < n; ++i) arr[p[i].second] = i, mapped[i] = p[i].first;
}
 
namespace sgt {
// Range increment, range maximum query
 
static const int MAXN = ::MAXN * 2;
int sz;
struct node { int l, r, lch, rch; int max, tag; } t[MAXN];
 
inline void apply(int idx, int val) {
    t[idx].max += val;
    t[idx].tag += val;
}
inline void push(int idx) {
    if (t[idx].lch == -1 || t[idx].tag == 0) return;
    apply(t[idx].lch, t[idx].tag);
    apply(t[idx].rch, t[idx].tag);
    t[idx].tag = 0;
}
inline void update(int idx) {
    if (t[idx].lch == -1) return;
    push(idx);
    t[idx].max = std::max(t[t[idx].lch].max, t[t[idx].rch].max);
}
 
inline int build(int L, int R) {
    int idx = sz++;
    t[idx].l = L, t[idx].r = R;
    t[idx].max = t[idx].tag = 0;
    if (L == R) {
        t[idx].lch = t[idx].rch = -1;
    } else {
        int M = (L + R) >> 1;
        t[idx].lch = build(L, M);
        t[idx].rch = build(M + 1, R);
    }
    return idx;
}
inline void rebuild(int L, int R) { sz = 0; build(L, R); }
 
int QL, QR, QV;
 
inline int query(int idx) {
    push(idx);
    if (t[idx].l >= QL && t[idx].r <= QR) return t[idx].max;
    int ans = 0;
    if (t[t[idx].lch].r >= QL) ans = std::max(ans, query(t[idx].lch));
    if (t[t[idx].rch].l <= QR) ans = std::max(ans, query(t[idx].rch));
    update(idx);
    return ans;
}
inline int query(int L, int R) { if (L > R) return 0; QL = L, QR = R; return query(0); }
 
inline void modify(int idx) {
    push(idx);
    if (t[idx].l >= QL && t[idx].r <= QR) { apply(idx, QV); return; }
    if (t[t[idx].lch].r >= QL) modify(t[idx].lch);
    if (t[t[idx].rch].l <= QR) modify(t[idx].rch);
    update(idx);
}
inline void modify(int L, int R, int V) { if (L > R) return; QL = L, QR = R, QV = V; modify(0); }
 
}
 
int ans = 0;
 
inline void solve()
{
    static std::pair<int, int> p[MAXN];
    for (int i = 0; i < n; ++i) p[i] = std::make_pair(y[i], x[i]);
    std::sort(p, p + n);
    for (int i = 0; i < n; ++i) x[i] = p[i].second, y[i] = p[i].first;
 
    int mid = w / 2;
    sgt::rebuild(-1, n - 1);
 
    std::stack<int> sl, sr;
    //sgt::modify(0, n - 1, w);
    sgt::modify(-1, -1, w);
    for (int i = 0; i < n; ++i) sgt::modify(i, i, w - y_mapped[i]);
    for (int i = 0; i < n; ++i) {
        assert(y[i] == i);
        ans = std::max(ans, y_mapped[i] + sgt::query(-1, y[i] - 1));
        if (x_mapped[x[i]] <= mid) {
            int last_w = w / 2, last_y = y[i];
            while (!sl.empty() && x[sl.top()] < x[i]) {
                sgt::modify(y[sl.top()], last_y - 1, -(last_w - (w / 2 - x_mapped[x[i]])));
                last_w = w / 2 - x_mapped[x[sl.top()]];
                last_y = y[sl.top()];
                sl.pop();
            }
            sgt::modify(sl.empty() ? -1 : y[sl.top()], last_y - 1, -(last_w - (w / 2 - x_mapped[x[i]])));
            sl.push(i);
        } else {
            int last_w = w, last_y = y[i];
            while (!sr.empty() && x[sr.top()] > x[i]) {
                sgt::modify(y[sr.top()], last_y - 1, -(last_w - x_mapped[x[i]]));
                last_w = x_mapped[x[sr.top()]];
                last_y = y[sr.top()];
                sr.pop();
            }
            sgt::modify(sr.empty() ? -1 : y[sr.top()], last_y - 1, -(last_w - x_mapped[x[i]]));
            sr.push(i);
        }
    }
    ans = std::max(ans, h + sgt::query(-1, n - 1));
}
 
int main()
{
    scanf("%d%d%d", &w, &h, &n);
    for (int i = 0; i < n; ++i) scanf("%d%d", &x[i], &y[i]);
    discretize(n, x, x_mapped);
    discretize(n, y, y_mapped);
 
    solve();
    std::swap(w, h);
    for (int i = 0; i < n; ++i) std::swap(x[i], y[i]);
    for (int i = 0; i < n; ++i) std::swap(x_mapped[i], y_mapped[i]);
    solve();
    printf("%d\n", ans * 2);
 
    return 0;
}


Measured memory_bytes: 24332