#include<bits/stdc++.h>
#define x first
#define y second
#define pii pair < int, int >
#define pb push_back

using namespace std;

int INF = 2e8, nr, N, W, H, ans, aint[1200009], real_val[300009];
vector < pii > currSet;
vector < pair < pii, int > > currA, currB;
pii P[300009];

void getSegms (vector < pii > Q, vector < pair < pii, int > > &ans)
{
    ans.clear ();
    int maxi = H, mini = 0;
    for (auto it = Q.begin (); it != Q.end (); it ++)
    {
        ans.pb ({{mini, maxi}, it->x});
        if (it->y >= H / 2) maxi = min (maxi, it->y);
        else mini = max (mini, it->y);
    }
}

void Build (int nod, int st, int dr)
{
    aint[nod] = -INF;
    if (st == dr) return ;
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    Build (f1, st, mij);
    Build (f2, mij + 1, dr);
}

void Update (int nod, int st, int dr, int pos, int val)
{
    if (st == dr)
    {
        if (val > aint[nod]) aint[nod] = val;
        return ;
    }
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    if (pos <= mij) Update (f1, st, mij, pos, val);
    else Update (f2, mij + 1, dr, pos, val);
    aint[nod] = max (aint[f1], aint[f2]);
}

int ansQry;
void Query (int nod, int st, int dr, int x, int y)
{
    if (x <= st && dr <= y)
    {
        if (x == st || aint[nod] > ansQry)
            ansQry = aint[nod];
        return ;
    }
    int mij = (st + dr) >> 1, f1 = nod << 1, f2 = f1 | 1;
    if (x <= mij) Query (f1, st, mij, x, y);
    if (mij < y) Query (f2, mij + 1, dr, x, y);
}

int getMax (int st, int dr) {Query (1, 1, nr, st, dr); return ansQry;}

void conquer (vector < pair < pii, int > > A, vector < pair < pii, int > > B)
{
    vector < pair < int, pii > > vx;
    for (int i=0; i<A.size (); i++)
        vx.pb ({A[i].x.x, {i, 0}}),
        vx.pb ({A[i].x.y, {i, 1}});
    for (int i=0; i<B.size (); i++)
        vx.pb ({B[i].x.x, {i, 2}}),
        vx.pb ({B[i].x.y, {i, 3}});
    sort (vx.begin (), vx.end ()), nr = 0;
    for (int i=0; i<vx.size (); i++)
    {
        nr += (i == 0 || vx[i].x != vx[i - 1].x);
        real_val[nr] = vx[i].x;
        int j = vx[i].y.x;
        if (vx[i].y.y == 0) A[j].x.x = nr;
        else
        if (vx[i].y.y == 1) A[j].x.y = nr;
        else
        if (vx[i].y.y == 2) B[j].x.x = nr;
        else B[j].x.y = nr;
    }
    ///end of normalization

    sort (A.begin (), A.end ()), sort (B.begin (), B.end ());
    int steps = 2;
    while (steps --)
    {
        auto it2 = B.begin (); Build (1, 1, nr);
        for (auto it = A.begin (); it != A.end (); it ++)
        {
            while (it2 != B.end () && it2->x.x <= it->x.x)
                Update (1, 1, nr, it2->x.y, real_val[it2->x.y] + it2->y), it2 ++;
            int curr = getMax (it->x.x, it->x.y) + it->y - real_val[it->x.x];
            if (curr > ans) ans = curr;
        }
        it2 = B.begin (); Build (1, 1, nr);
        for (auto it = A.begin (); it != A.end (); it ++)
        {
            while (it2 != B.end () && it2->x.x <= it->x.x)
                Update (1, 1, nr, it2->x.y, it2->y), it2 ++;
            int curr = getMax (it->x.y, nr) + it->y + real_val[it->x.y] - real_val[it->x.x];
            if (curr > ans) ans = curr;
        }
        if (steps) swap (A, B);
    }
}

void solve (int st, int dr)
{
    if (st == dr) return ;
    int mij = (st + dr) >> 1;

    currSet.clear ();
    for (int i=mij; i>=st; i--)
        currSet.pb ({P[mij].x - P[i].x, P[i].y});
    getSegms (currSet, currA);

    currSet.clear ();
    for (int i=mij + 1; i<=dr; i++)
        currSet.pb ({P[i].x - P[mij].x, P[i].y});
    getSegms (currSet, currB);

    conquer (currA, currB);

    solve (st, mij);
    solve (mij + 1, dr);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &W, &H, &N);
for (int i=2; i<=N + 1; i++)
    scanf ("%d %d", &P[i].x, &P[i].y);
sort (P + 2, P + N + 2), P[1] = {0, 0}, P[N + 2] = {W, 0};
solve (1, N + 2);
for (int i=2; i<=N + 1; i++)
    swap (P[i].x, P[i].y);
sort (P + 2, P + N + 2), swap (W, H), P[1] = {0, 0}, P[N + 2] = {W, 0};;
solve (1, N + 2);
printf ("%d\n", 2 * ans);
return 0;
}


Measured memory_bytes: 40500