#include<cstdio>
#include<algorithm>
#define lc (o<<1)
#define rc ((o<<1)|1)
#define mid ((l+r)>>1)
using namespace std;
const int N=300010;
int X,Y,n,nx,ny,x[N],y[N],lsx[N],lsy[N],p[N],s1[N],s2[N],top1,top2,tmp,ans;
struct xd_tree{int mx,del;} t[N<<2];
bool cmpx(int a,int b) {return x[a]<x[b];}
bool cmpy(int a,int b) {return y[a]<y[b];}
int read() {
	int tmp=0, fh=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
	while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
	return tmp*fh;
}
void build(int o,int l,int r,bool isx) {
	t[o].del=0;
	if (l<r) {
		build(lc,l,mid,isx); build(rc,mid+1,r,isx);
		t[o].mx=max(t[lc].mx,t[rc].mx);
	} else t[o].mx=(isx)?Y-lsx[l-1]:X-lsy[l-1];
}
void add(int o,int l,int r,int lt,int rt,int x) {
	//if (o==1) printf("add %d %d %d\n",lt,rt,x);
	if (l>=lt&&r<=rt) {
		t[o].del+=x; t[o].mx+=x; return;
	}
	if (t[o].del!=0) {
		t[lc].del+=t[o].del; t[lc].mx+=t[o].del;
		t[rc].del+=t[o].del; t[rc].mx+=t[o].del;
		t[o].del=0;
	}
	if (lt<=mid) add(lc,l,mid,lt,rt,x);
	if (rt>mid) add(rc,mid+1,r,lt,rt,x);
	t[o].mx=max(t[lc].mx,t[rc].mx);
}
int query(int o,int l,int r,int lt,int rt) {
	//printf("query %d %d %d %d %d\n",o,l,r,lt,rt);
	if (l>=lt&&r<=rt) return t[o].mx;
	if (t[o].del!=0) {
		t[lc].del+=t[o].del; t[lc].mx+=t[o].del;
		t[rc].del+=t[o].del; t[rc].mx+=t[o].del;
		t[o].del=0;
	}
	int tmp=0;
	if (lt<=mid) tmp=max(tmp,query(lc,l,mid,lt,rt));
	if (rt>mid) tmp=max(tmp,query(rc,mid+1,r,lt,rt));
	return tmp;
}
int main() {
	//freopen("color2.in","r",stdin);
	X=read(); Y=read(); n=read();
	for (int i=1;i<=n;i++) {
		lsx[i]=x[i]=read(); lsy[i]=y[i]=read();
	}
	nx=ny=n; sort(lsx+1,lsx+nx+1); sort(lsy+1,lsy+n+1);
	lsx[++nx]=X; lsy[++ny]=Y;
	nx=unique(lsx+1,lsx+nx+1)-lsx-1; ny=unique(lsy+1,lsy+ny+1)-lsy-1;
	for (int i=1;i<=n;i++) {
		x[i]=lower_bound(lsx+1,lsx+nx+1,x[i])-lsx;
		y[i]=lower_bound(lsy+1,lsy+ny+1,y[i])-lsy;
		p[i]=i;
	}
	sort(p+1,p+n+1,cmpy); build(1,1,ny+1,0);
	//printf("QAQ\n");
	for (int i=1,j=1;i<=ny;i++) {
		tmp=lsy[i]+query(1,1,ny+1,1,i);
		ans=max(ans,tmp);
		while (j<=n&&y[p[j]]==i) {
			if (lsx[x[p[j]]]>X/2) {
				add(1,1,ny+1,y[s1[top1]]+1,i,lsx[x[p[j]]]-X);
				while (top1&&x[s1[top1]]>=x[p[j]]) {
					add(1,1,ny+1,y[s1[top1-1]]+1,y[s1[top1]]+1,lsx[x[p[j]]]-lsx[x[s1[top1]]]);
					top1--;
				}
				s1[++top1]=p[j];
			} else {
				add(1,1,ny+1,y[s2[top2]]+1,i,-lsx[x[p[j]]]);
				while (top2&&x[s2[top2]]<=x[p[j]]) {
					add(1,1,ny+1,y[s2[top2-1]]+1,y[s2[top2]]+1,lsx[x[s2[top2]]]-lsx[x[p[j]]]);
					top2--;
				}
				s2[++top2]=p[j];
			}
			j++;
		}
		//printf("%d %d %d\n",i,j,tmp);
	}
	//printf("QAQ\n");
	top1=top2=0;
	sort(p+1,p+n+1,cmpx); build(1,1,nx+1,1);
	for (int i=1,j=1;i<=nx;i++) {
		tmp=lsx[i]+query(1,1,nx+1,1,i);
		ans=max(ans,tmp);
		while (j<=n&&x[p[j]]==i) {
			if (lsy[y[p[j]]]>Y/2) {
				add(1,1,nx+1,x[s1[top1]]+1,i,lsy[y[p[j]]]-Y);
				while (top1&&y[s1[top1]]>=y[p[j]]) {
					add(1,1,nx+1,x[s1[top1-1]]+1,x[s1[top1]]+1,lsy[y[p[j]]]-lsy[y[s1[top1]]]);
					top1--;
				}
				s1[++top1]=p[j];
			} else {
				add(1,1,nx+1,x[s2[top2]]+1,i,-lsy[y[p[j]]]);
				while (top2&&y[s2[top2]]<=y[p[j]]) {
					add(1,1,nx+1,x[s2[top2-1]]+1,x[s2[top2]]+1,lsy[y[s2[top2]]]-lsy[y[p[j]]]);
					top2--;
				}
				s2[++top2]=p[j];
			}
			j++;
		}
		//printf("%d %d %d\n",i,j,tmp);
	}
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 17792