#include<bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;

int W, H, N, ans;
vector<pii> P;

void add(int idx, int val, deque<pii> &dq) {
    while(!dq.empty() && dq.back().first <= val) dq.pop_back();
    dq.push_back(pii(val, idx));
}
void relax(int idx, deque<pii> &dq) {
    while(!dq.empty() && dq.front().second > idx) dq.pop_front();
}

void solve(int lo, int hi, vector<pii> &V) {
    if(lo >= hi) return;
    if(V.size() == 0) {
        ans = max(ans, hi - lo + W);
        return;
    }

    int mid1 = (lo + hi) / 2;
    int mid2 = (lo + hi + 1) / 2;

    vector<pii> v1, v2;
    for(int i = 0; i < V.size(); i++) {
        if(V[i].second < mid1) v1.push_back(V[i]);
        if(V[i].second > mid2) v2.push_back(V[i]);
    }

    solve(lo, mid1, v1);
    solve(mid2, hi, v2);

    vector<pair<pii, int> > le, ri;

    int mn = lo;
    int mx = hi;
    for(int i = (int)V.size() - 1; i >= 0; i--) {
        if(V[i].first > W / 2) continue;
        if(mn == mx) break;
        le.push_back({ pii(mn, mx), W / 2 - V[i].first });

        if(V[i].second <= mid1) mn = max(mn, V[i].second);
        if(V[i].second >= mid2) mx = min(mx, V[i].second);
    }
    if(mn < mx) le.push_back({ pii(mn, mx), W / 2 });

    mn = lo;
    mx = hi;
    for(int i = 0; i < V.size(); i++) {
        if(V[i].first < W / 2) continue;
        if(mn == mx) break;
        ri.push_back({ pii(mn, mx), V[i].first - W / 2 });

        if(V[i].second <= mid1) mn = max(mn, V[i].second);
        if(V[i].second >= mid2) mx = min(mx, V[i].second);
    }
    if(mn < mx) ri.push_back({ pii(mn, mx), W / 2 });

    deque<pii> dq1, dq2;
    int pos1 = (int)ri.size() - 1;
    int pos2 = (int)ri.size() - 1;
    for(int i = (int)le.size() - 1; i >= 0; i--) {
        int l = le[i].first.first;
        int r = le[i].first.second;
        while(pos1 >= 0 && !(ri[pos1].first.first <= l && r <= ri[pos1].first.second)) {
            int ll = ri[pos1].first.first;
            int rr = ri[pos1].first.second;
            if(l <= ll && ll <= r) {
                add(pos1, -ll + ri[pos1].second, dq1);
            }
            else if(l <= rr && rr <= r) {
                add(pos1, rr + ri[pos1].second, dq1);
            }
            pos1--;
        }
        while(pos2 > pos1 && l <= ri[pos2].first.first && ri[pos2].first.second <= r) {
            int ll = ri[pos2].first.first;
            int rr = ri[pos2].first.second;
            add(pos2, rr - ll + ri[pos2].second, dq2);
            pos2--;
        }
        relax(pos2, dq1);

        if(pos1 >= 0) {
            ans = max(ans, r - l + ri[pos1].second + le[i].second);
        }
        if(dq1.size()) {
            int p = dq1.front().second;
            if(l <= ri[p].first.first && ri[p].first.first <= r) ans = max(ans, dq1.front().first + le[i].second + r);
            else ans = max(ans, dq1.front().first + le[i].second - l);
        }
        if(dq2.size()) {
            ans = max(ans, dq2.front().first + le[i].second);
        }
    }
}

int main() {
    scanf("%d %d %d", &W, &H, &N);
    W <<= 1;
    H <<= 1;

    P.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &P[i].first, &P[i].second);
        P[i].first <<= 1;
        P[i].second <<= 1;
    }

    sort(P.begin(), P.end());
    ans = max(ans, W + 2);
    solve(0, H, P);

    swap(W, H);
    for(int i = 0; i < N; i++) {
        swap(P[i].first, P[i].second);
    }

    sort(P.begin(), P.end());
    ans = max(ans, W + 2);
    solve(0, H, P);

    printf("%d", ans);
}


Measured memory_bytes: 20340