#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int read()
{
	char a=getchar();int res=0,f=1;
	while(a<'0'||a>'9'){if(a=='-')f=-1;a=getchar();}
	while(a>='0'&&a<='9')res=res*10+a-'0',a=getchar();
	return res*f;
}
const int inf=0x3f3f3f3f;
struct TR{
	int l,r;
	int tag,max;
}tr[300005*4];
#define ls ro<<1
#define rs ro<<1|1
void build(int ro,int lt,int rt)
{
	tr[ro].l=lt; tr[ro].r=rt;
	tr[ro].max=tr[ro].tag=0;
	if(lt==rt) return ;
	int mid=(lt+rt)>>1;
	build(ls,lt,mid); build(rs,mid+1,rt);
}
void ins(int ro,int lt,int rt,int c)
{
	if(lt>rt) return ;
	if(tr[ro].l==lt&&tr[ro].r==rt)
		tr[ro].tag+=c,tr[ro].max+=c;
	else {
		int mid=(tr[ro].l+tr[ro].r)>>1;
		if(rt<=mid) ins(ls,lt,rt,c); else if(lt>mid) ins(rs,lt,rt,c);
		else ins(ls,lt,mid,c),ins(rs,mid+1,rt,c);
		tr[ro].max=tr[ro].tag+max(tr[ls].max,tr[rs].max);
	}
}
#undef ls
#undef rs
struct P{
	int x,y;
}p[300005];
bool comy(P a,P b){return a.y<b.y;}
struct N{
	int id,v;
	N(){}
	N(int a,int b):id(a),v(b){}
}q1[300005*2],q2[300005*2];
int n,m,K,ans=0;
void work()
{
	sort(p+1,p+1+K,comy);
	int t1=0,t2=0,mid=n>>1;
	q1[++t1]=N(-1,mid); q1[++t1]=N(0,0);
	q2[++t2]=N(-1,mid+1); q2[++t2]=N(0,n);
	build(1,0,K); ins(1,0,0,n);
	for(int i=1;i<=K;i++){
		ans=max(ans,(tr[1].max+p[i].y)*2);
		if(p[i].x<=mid){
			while(t1&&p[i].x>q1[t1].v){
				ins(1,q1[t1-1].id+1,q1[t1].id,q1[t1].v-p[i].x);
				t1--;
			} q1[++t1]=N(i-1,p[i].x);
		} else{
			while(t2&&p[i].x<q2[t2].v){
				ins(1,q2[t2-1].id+1,q2[t2].id,p[i].x-q2[t2].v);
				t2--;
			} q2[++t2]=N(i-1,p[i].x);
		} q1[++t1]=N(i,0); q2[++t2]=N(i,n);
		ins(1,i,i,n-p[i].y);
	} ans=max(ans,(tr[1].max+m)*2);
}
int main()
{
	n=read(); m=read(); K=read();
	for(int i=1;i<=K;i++)
		p[i].x=read(),p[i].y=read();
	work();
	for(int i=1;i<=K;i++)
		swap(p[i].x,p[i].y);
	swap(n,m);
	work(); printf("%d\n",ans);
	return 0;
}
