// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 3e5 + 5;
const int RNG = 1e8 + 5;

int W, H;
int N;
Pii A[MAXN];

void input()
{
    read(W); read(H); read(N);
    for (int i = 1; i <= N; ++i) {
        read(A[i].x); read(A[i].y);
    }
    A[++N] = MP(0, 0);
    A[++N] = MP(0, H);
    A[++N] = MP(W, 0);
    A[++N] = MP(W, H);
}

namespace SEGT
{

const int SIZE = (1 << 20) + 5;

int max[SIZE], addt[SIZE];

#define LC (u << 1)
#define RC (u << 1 | 1)

void build(int u, int l, int r)
{
    max[u] = -oo; addt[u] = 0;
    if (l == r)
        return;
    int mid = (l + r) >> 1;
    build(LC, l, mid);
    build(RC, mid + 1, r);
}

void add(int u, int l, int r, int ql, int qr, int x)
{
    if (ql <= l && r <= qr) {
        max[u] += x; addt[u] += x;
        return;
    }
    int mid = (l + r) >> 1;
    if (ql <= mid)
        add(LC, l, mid, ql, qr, x);
    if (mid < qr)
        add(RC, mid + 1, r, ql, qr, x);
    max[u] = std::max(max[LC], max[RC]) + addt[u];
}

void modify(int u, int l, int r, int p, int x)
{
    if (l == r) {
        max[u] = x; addt[u] = 0;
        return;
    }
    int mid = (l + r) >> 1;
    if (p <= mid)
        modify(LC, l, mid, p, x);
    else
        modify(RC, mid + 1, r, p, x);
    max[u] = std::max(max[LC], max[RC]) + addt[u];
}

}

inline void add(int l, int r, int x)
{
    if (l < r)
        SEGT::add(1, 1, N, l, r - 1, x);
}

int calc()
{
    static int P[MAXN], Q[MAXN];
    int p = 0, q = 0;
    int ret = 0;

    std::sort(A + 1, A + N + 1);
    SEGT::build(1, 1, N);
    P[0] = Q[0] = 1;
    for (int i = 1; i <= N; ++i) {
        chkmax(ret, SEGT::max[1] + A[i].x);
        if (A[i].y <= H / 2) {
            for (; p > 0 && A[P[p]].y <= A[i].y; --p) {
                add(P[p - 1], P[p], A[P[p]].y);
            }
            add(P[p], i, -A[i].y);
            P[++p] = i;
        } else {
            for (; q > 0 && A[Q[q]].y >= A[i].y; --q) {
                add(Q[q - 1], Q[q], H - A[Q[q]].y);
            }
            add(Q[q], i, A[i].y - H);
            Q[++q] = i;
        }
        SEGT::modify(1, 1, N, i, -A[i].x + H);
    }
    chkmax(ret, SEGT::max[1] + W);

    return ret;
}

void solve()
{
    int ans = 0;
    chkmax(ans, calc());
    std::swap(W, H);
    for (int i = 1; i <= N; ++i) {
        std::swap(A[i].x, A[i].y);
    }
    chkmax(ans, calc());
    ans *= 2;

    printf("%d\n", ans);
}

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

    input();
    solve();
}

// 有一种人的理财学不过是借债不还，所以有一种人的道学，
// 只是教训旁人，并非自己有什么道德。
//   --钱钟书


Measured memory_bytes: 12544