#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int N = 3e+5+5;

int n,W,H;
struct point{
	int x,y;
	point(const int x_=0,const int y_=0){x=x_;y=y_;}
	void init(){x=get(),y=get();}
}a[N],lef[N],rig[N];
int ans;
int kl,kr;
set<int>s;
int num[N];
struct section{
	int l,r,w;
	section(const int l_=0,const int r_=0,const int w_=0){l=l_;r=r_;w=w_;}
}L[N*2],R[N*2];
int sl,sr;
int tot;
struct node{
	int l,r;
	int v1,v2;
}tree1[N*2],tree2[N*2];

bool cmp1(point a,point b){return a.x<b.x;}
bool cmp2(section a,section b){return a.l<b.l;}

int find(int x){int l=1,r=n+2,w=0;for(;l<=r;){int mid=(l+r)/2;if (x<num[mid])r=mid-1;else l=mid+1,w=mid;}return w;}

void build(int &now,int l,int r){
	now=++tot;
	tree1[now].v1=tree1[now].v2=tree2[now].v1=tree2[now].v2=-1e+9;
	if (l==r)return;
	int mid=(l+r)/2;
	build(tree1[now].l,l,mid);
	build(tree1[now].r,mid+1,r);
	tree2[now].l=tree1[now].l;
	tree2[now].r=tree1[now].r;
}

void change1(int now,int l,int r,int x,int v1,int v2){
	if (l==r){tree1[now].v1=v1;tree1[now].v2=v2;return;}
	int mid=(l+r)/2;
	if (x<=mid)change1(tree1[now].l,l,mid,x,v1,v2);
	else change1(tree1[now].r,mid+1,r,x,v1,v2);
	tree1[now].v1=max(tree1[tree1[now].l].v1,tree1[tree1[now].r].v1);
	tree1[now].v2=max(tree1[tree1[now].l].v2,tree1[tree1[now].r].v2);
}

void change2(int now,int l,int r,int x,int v1,int v2){
	if (l==r){tree2[now].v1=v1;tree2[now].v2=v2;return;}
	int mid=(l+r)/2;
	if (x<=mid)change2(tree2[now].l,l,mid,x,v1,v2);
	else change2(tree2[now].r,mid+1,r,x,v1,v2);
	tree2[now].v1=max(tree2[tree2[now].l].v1,tree2[tree2[now].r].v1);
	tree2[now].v2=max(tree2[tree2[now].l].v2,tree2[tree2[now].r].v2);
}

int getv11(int now,int l,int r,int x,int y){if (x<=l&&r<=y)return tree1[now].v1;int mid=(l+r)/2,ans=-1e+9;if (x<=mid)ans=getv11(tree1[now].l,l,mid,x,y);if (y>mid)ans=max(ans,getv11(tree1[now].r,mid+1,r,x,y));return ans;}

int getv12(int now,int l,int r,int x,int y){if (x<=l&&r<=y)return tree1[now].v2;int mid=(l+r)/2,ans=-1e+9;if (x<=mid)ans=getv12(tree1[now].l,l,mid,x,y);if (y>mid)ans=max(ans,getv12(tree1[now].r,mid+1,r,x,y));return ans;}

int getv21(int now,int l,int r,int x,int y){if (x<=l&&r<=y)return tree2[now].v1;int mid=(l+r)/2,ans=-1e+9;if (x<=mid)ans=getv21(tree2[now].l,l,mid,x,y);if (y>mid)ans=max(ans,getv21(tree2[now].r,mid+1,r,x,y));return ans;}

int getv22(int now,int l,int r,int x,int y){if (x<=l&&r<=y)return tree2[now].v2;int mid=(l+r)/2,ans=-1e+9;if (x<=mid)ans=getv22(tree2[now].l,l,mid,x,y);if (y>mid)ans=max(ans,getv22(tree2[now].r,mid+1,r,x,y));return ans;}

void solve(int W,int H){
	int mid=W/2;
	kl=0,kr=0;
	fo(i,1,n)
	if (a[i].x<=mid)lef[++kl]=a[i];else rig[++kr]=a[i];
	fo(i,1,n)num[i]=a[i].y;
	num[n+1]=0;num[n+2]=H;
	sort(num+1,num+3+n);
	sort(lef+1,lef+1+kl,cmp1);
	sort(rig+1,rig+1+kr,cmp1);
	
	s.clear();
	s.insert(0);s.insert(H);
	sl=sr=0;
	fd(i,kl,1){
		set<int>::iterator h=s.upper_bound(lef[i].y);
		section u;
		if (lef[i].y==H)u.r=H;else u.r=*h;
		h--;u.l=*h;u.w=lef[i].x;
		L[++sl]=u;
		s.insert(lef[i].y);
	}
	set<int>::iterator h1=s.begin();
	int lst=0;
	for(;h1!=s.end();h1++){
		if (h1!=s.begin())L[++sl]=section(lst,*h1,0);
		lst=*h1;
	}
	sort(L+1,L+1+sl,cmp2);
	
	s.clear();
	s.insert(0);s.insert(H);
	fo(i,1,kr){
		set<int>::iterator h=s.upper_bound(rig[i].y);
		section u;
		if (rig[i].y==H)u.r=H;else u.r=*h;
		h--;u.l=*h;u.w=rig[i].x;
		R[++sr]=u;
		s.insert(rig[i].y);
	}
	h1=s.begin();
	lst=0;
	for(;h1!=s.end();h1++){
		if (h1!=s.begin())R[++sr]=section(lst,*h1,W);
		lst=*h1;
	}
	sort(R+1,R+1+sr,cmp2);
	
	int rt;
	tot=0;
	build(rt,1,n+2);
	int hl=1,hr=1;
	while(hl<=sl||hr<=sr){
		int ll=1e+9;
		if (hl<=sl)ll=min(ll,L[hl].l);
		if (hr<=sr)ll=min(ll,R[hr].l);
		int ql=hl,qr=hr;
		for(;hl<=sl&&L[hl].l==ll;hl++)change1(1,1,n+2,find(L[hl].r),L[hl].r-L[hl].w,-L[hl].w);
		for(;hr<=sr&&R[hr].l==ll;hr++)change2(1,1,n+2,find(R[hr].r),R[hr].r+R[hr].w,R[hr].w);
		fo(i,ql,hl-1){
			int w=find(L[i].r);
			ans=max(ans,getv21(1,1,n+2,find(L[i].l),w)-L[i].l-L[i].w);
			ans=max(ans,getv22(1,1,n+2,w,n+2)+L[i].r-L[i].l-L[i].w);
		}
		fo(i,qr,hr-1){
			int w=find(R[i].r);
			ans=max(ans,getv11(1,1,n+2,find(R[i].l),w)+R[i].w-R[i].l);
			ans=max(ans,getv12(1,1,n+2,w,n+2)+R[i].r-R[i].l+R[i].w);
		}
	}
}

int main(){
	W=get();H=get();n=get();
	fo(i,1,n)a[i].init();
	solve(W,H);
	fo(i,1,n)swap(a[i].x,a[i].y);
	solve(H,W);
	printf("%d\n",ans*2);
	return 0;
}

Measured memory_bytes: 51712