// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=300000+10;

int n,w,h;
struct Point { int x,y; } p[N];

#define ls (o<<1)
#define rs (o<<1|1)
int maxv[N<<2],addv[N<<2];
void pushup(int o) { maxv[o]=max(maxv[ls],maxv[rs]); }
void pushdown(int o) {
	if (addv[o]) {
		maxv[ls]+=addv[o],addv[ls]+=addv[o];
		maxv[rs]+=addv[o],addv[rs]+=addv[o];
		addv[o]=0;
	}
}
void build() { memset(maxv,0,sizeof(maxv)),memset(addv,0,sizeof(addv)); }
void modify(int o,int l,int r,int ql,int qr,int w) {
	if (ql<=l&&r<=qr) { maxv[o]+=w,addv[o]+=w; return; }
	int mid=(l+r)>>1; pushdown(o);
	if (ql<=mid) modify(ls,l,mid,ql,qr,w);
	if (qr>mid) modify(rs,mid+1,r,ql,qr,w);
	pushup(o);
}
int query(int o,int l,int r,int ql,int qr) {
	if (ql<=l&&r<=qr) return maxv[o];
	int mid=(l+r)>>1,res=0; pushdown(o);
	if (ql<=mid) res=max(res,query(ls,l,mid,ql,qr));
	if (qr>mid) res=max(res,query(rs,mid+1,r,ql,qr));
	pushup(o); return res;
}
#undef ls
#undef rs

int x[N],u[N],d[N];
int su[N],topu=0,sd[N],topd=0;
int calc(int n,int w,int h) {
	build(),su[topu=1]=sd[topd=1]=0; int mid=h>>1,res=0;
	for (int i=1,j=0;i<=n;) {
		++j,x[j]=p[i].x,u[j]=h-mid,d[j]=mid;
		while (i<=n&&p[i].x==x[j]) {
			if (p[i].y>=mid) u[j]=min(u[j],p[i].y-mid);
			if (p[i].y<=mid) d[j]=min(d[j],mid-p[i].y);
			++i;
		}
		while (topu&&u[su[topu]]>u[j]) {
			int t=su[topu--];
			modify(1,1,n,su[topu]+1,t,u[j]-u[t]);
		}
		su[++topu]=j;
		while (topd&&d[sd[topd]]>d[j]) {
			int t=sd[topd--];
			modify(1,1,n,sd[topd]+1,t,d[j]-d[t]);
		}
		sd[++topd]=j;
		modify(1,1,n,j,j,u[j]+d[j]-x[j-1]);
		res=max(res,query(1,1,n,1,j)+p[i].x);
	}
	return res;
}

int main() {
	w=read(),h=read(),n=read();
	for (int i=1;i<=n;++i) p[i].x=read(),p[i].y=read();
	int ans=0;
	sort(p+1,p+n+1,[](Point a,Point b) { return a.x<b.x; });
	p[0].x=0,p[n+1].x=w;
	for (int i=0;i<=n;++i) ans=max(ans,h+(p[i+1].x-p[i].x));
	ans=max(ans,calc(n,w,h));
	for (int i=1;i<=n;++i) swap(p[i].x,p[i].y);
	sort(p+1,p+n+1,[](Point a,Point b) { return a.x<b.x; });
	p[0].x=0,p[n+1].x=h;
	for (int i=0;i<=n;++i) ans=max(ans,w+(p[i+1].x-p[i].x));
	ans=max(ans,calc(n,h,w));
	printf("%d\n",ans<<1);
	return 0;
}