#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 300005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
struct node {
    int l,r,ad,v;
}tr[MAXN * 4];
int W,H,N,ans;
pii p[MAXN];
int sta[2][MAXN],top[2];
void update(int u) {
    tr[u].v = max(tr[u << 1].v,tr[u << 1 | 1].v);
}
void addlz(int u,int v) {
    tr[u].ad += v;tr[u].v += v;
}
void pushdown(int u) {
    if(tr[u].ad) {
        addlz(u << 1,tr[u].ad);
        addlz(u << 1 | 1,tr[u].ad);
        tr[u].ad = 0;
    }
}
void build(int u,int l,int r) {
    tr[u].l = l;tr[u].r = r;tr[u].ad = 0;
    if(l == r) {
        tr[u].v =  H - p[l].fi;return;
    }
    int mid = (l + r) >> 1;
    build(u << 1,l,mid);
    build(u << 1 | 1,mid + 1,r);
    update(u);
}
void add(int u,int l,int r,int v) {
    if(l > r || !v) return;
    if(tr[u].l == l && tr[u].r == r) {
        addlz(u,v);return;
    }
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) add(u << 1,l,r,v);
    else if(l > mid) add(u << 1 | 1,l,r,v);
    else {add(u << 1,l,mid,v);add(u << 1 | 1,mid + 1,r,v);}
    update(u);
}
int query(int u,int l,int r) {
    if(l > r) return 0;
    if(tr[u].l == l && tr[u].r == r) return tr[u].v;
    pushdown(u);
    int mid = (tr[u].l + tr[u].r) >> 1;
    if(r <= mid) return query(u << 1,l,r);
    else if(l > mid) return query(u << 1 | 1,l,r);
    else return max(query(u << 1,l,mid),query(u << 1 | 1,mid + 1,r));
}
int Calc() {
    sort(p + 1,p + N + 1);
    build(1,0,N);
    top[0] = top[1] = 0;
    memset(sta,0,sizeof(sta));
    int res = 0;
    for(int i = 1 ; i <= N ; ++i) {
        res = max(res,query(1,0,i - 1) + p[i].fi);
        if(p[i].se > H / 2) {
            int pre = H,pos = i;
            while(top[1] && p[sta[1][top[1]]].se > p[i].se) {
                add(1,sta[1][top[1]],pos - 1,-pre);
                pre = p[sta[1][top[1]]].se;
                pos = sta[1][top[1]];
                --top[1];
            }
            add(1,sta[1][top[1]],pos - 1,-pre);
            add(1,sta[1][top[1]],i - 1,p[i].se);
            sta[1][++top[1]] = i;
        }
        else {
            int pre = 0,pos = i;
            while(top[0] && p[sta[0][top[0]]].se < p[i].se) {
                add(1,sta[0][top[0]],pos - 1,pre);
                pre = p[sta[0][top[0]]].se;
                pos = sta[0][top[0]];
                --top[0];
            }
            add(1,sta[0][top[0]],pos - 1,pre);
            add(1,sta[0][top[0]],i - 1,-p[i].se);
            sta[0][++top[0]] = i;
        }

    }
    res = max(res,query(1,0,N) + W);
    return 2 * res;
}
void Solve() {
    read(W);read(H);read(N);
    for(int i = 1 ; i <= N ; ++i) {
        read(p[i].fi);read(p[i].se);
    }
    ans = 2 * max(H,W) + 1;
    ans = max(ans,Calc());
    for(int i = 1 ; i <= N ; ++i) swap(p[i].fi,p[i].se);
    swap(W,H);
    ans = max(ans,Calc());
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 22912