#include <bits/stdc++.h>

using namespace std;

//#define FILE_IO

typedef pair<int, int> pii;

const int NMAX = 3e5 + 10;

int W, H, N, ans;
pii p[NMAX];

class SegmentTree
{
private:
    int N, ST, DR;
    int aint[4 * NMAX];
    int add[4 * NMAX];

    void B(int nod, int st, int dr)
    {
        aint[nod] = add[nod] = 0;
        //aint[nod] = -(1 << 30), add[nod] = 0;
        if(st == dr)    return;
        int mij = st + (dr - st) / 2;
        B(nod * 2, st, mij);
        B(nod * 2 + 1, mij + 1, dr);
    }

    void U(int nod, int st, int dr, int pos, int val)
    {
        if(st == dr)
        {
            aint[nod] = val;
            add[nod] = 0;
            return;
        }

        int mij = st + (dr - st) / 2;

        if(add[nod])
        {
            U(nod * 2, st, mij, st, dr, add[nod]);
            U(nod * 2 + 1, mij + 1, dr, st, dr, add[nod]);
            add[nod] = 0;
        }

        if(pos <= mij)  U(nod * 2, st, mij, pos, val);
        else            U(nod * 2 + 1, mij + 1, dr, pos, val);

        aint[nod] = max(aint[nod * 2], aint[nod * 2 + 1]);
    }

    void U(int nod, int st, int dr, int sti, int dri, int val)
    {
        if(sti <= st && dr <= dri)
        {
            aint[nod] += val;
            add[nod] += val;
            return;
        }

        int mij = st + (dr - st) / 2;

        if(add[nod])
        {
            U(nod * 2, st, mij, st, dr, add[nod]);
            U(nod * 2 + 1, mij + 1, dr, st, dr, add[nod]);
            add[nod] = 0;
        }

        if(sti <= mij)  U(nod * 2, st, mij, sti, dri, val);
        if(mij < dri)   U(nod * 2 + 1, mij + 1, dr, sti, dri, val);

        aint[nod] = max(aint[nod * 2], aint[nod * 2 + 1]);
    }

public:
    int init(int _N, int st, int dr)
    {
        N = _N, ST = st, DR = dr;
        B(1, ST, DR);
    }

    void update(int st, int dr, int val)
    {
        if(st > dr) return;
        U(1, ST, DR, st, dr, val);
    }

    void update(int pos, int val)
    {
        U(1, ST, DR, pos, val);
    }

    int query()
    {
        return aint[1];
    }
};
SegmentTree aint;

void solve(int W, int H, int N)
{
    sort(p + 1, p + N + 1);
    p[0] = {0, 0};
    p[N + 1] = {W, 0};

    aint.init(N + 2, 0, N + 1);
    stack<pii> stkmn, stkmx;
    stkmn.push({0, 0});
    stkmx.push({H, 0});
    aint.update(0, -p[0].first + H);

    for(int i = 1; i <= N + 1; i++)
    {
        int val = aint.query() + p[i].first;
        ans = max(ans, val);

        aint.update(i, -p[i].first + H);
        int h = p[i].second;
        if(h <= H / 2)
        {
            int lst = stkmx.top().second;
            while(!stkmx.empty())
            {
                if(stkmx.top().first >= h)   break;
                int pos = stkmx.top().second;
                int hh = stkmx.top().first;
                stkmx.pop();
                lst = stkmx.top().second;
                aint.update(lst, pos - 1, hh);
            }
            stkmx.push({h, i});
            aint.update(lst, i - 1, -h);
        }
        else
        {
            int lst = stkmn.top().second;
            aint.update(lst, i - 1, -H);
            while(!stkmn.empty())
            {
                if(stkmn.top().first <= h)  break;
                int pos = stkmn.top().second;
                int hh = stkmn.top().first;
                stkmn.pop();
                lst = stkmn.top().second;
                aint.update(lst, pos - 1, -hh);
            }
            stkmn.push({h, i});
            aint.update(lst, i - 1, h);
        }
    }
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d%d", &W, &H, &N);
    for(int i = 1; i <= N; i++) scanf("%d%d", &p[i].first, &p[i].second);

    ans = max(W, H) + 1;

    solve(W, H, N);

    swap(W, H);
    for(int i = 1; i <= N; i++) swap(p[i].first, p[i].second);

    solve(W, H, N);

    printf("%d\n", 2 * ans);

    return 0;
}


Measured memory_bytes: 13212