#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
struct Point
{
	int x,y;
}p[303030];
bool cmpx(const Point &p1,const Point &p2)
{
	return p1.x<p2.x;
}
bool cmpy(const Point &p1,const Point &p2)
{
	return p1.y<p2.y;
}
struct Node
{
	Node *lch,*rch;
	int l,r;
	int ma,lz;
}*rt;
int nx[303030];
Node *Build(int l,int r)
{
	Node *ret=new Node;
	ret->l=l;
	ret->r=r;
	ret->lz=0;
	ret->ma=nx[l];
	if(l==r)
	{
		ret->lch=ret->rch=NULL;
		return ret;
	}
	int mid=(l+r)>>1;
	ret->lch=Build(l,mid);
	ret->rch=Build(mid+1,r);
	return ret;
}
void update(Node *x)
{
	x->ma=max(x->lch->ma,x->rch->ma);
}
void add(Node *x,int v)
{
	x->ma+=v;
	x->lz+=v;
}
void down(Node *x)
{
	if(x->lz)
	{
		add(x->lch,x->lz);
		add(x->rch,x->lz);
		x->lz=0;
	}
}
void modify(Node *x,int l,int r,int v)
{
	if(l<=x->l&&r>=x->r)
	{
		add(x,v);
		return;
	}
	int mid=(x->l+x->r)>>1;
	down(x);
	if(l<=mid)
		modify(x->lch,l,r,v);
	if(mid<r)
		modify(x->rch,l,r,v);
	update(x);
}
int query(Node *x,int l,int r)
{
	if(l<=x->l&&r>=x->r)
		return x->ma;
	int mid=(x->l+x->r)>>1,ret=-214748364;
	down(x);
	if(l<=mid)
		ret=max(ret,query(x->lch,l,r));
	if(mid<r)
		ret=max(ret,query(x->rch,l,r));
	return ret;
}
int st1[303030],stv1[303030],sn1;
int st2[303030],stv2[303030],sn2;
int main()
{
	int w,h,n,ans=0;
	scanf("%d%d%d",&w,&h,&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&p[i].x,&p[i].y);
		if(p[i].x==0||p[i].x==w||p[i].y==0||p[i].y==h)
		{
			i--;
			n--;
		}
	}
	++n;
	p[n].x=0;
	p[n].y=0;
	++n;
	p[n].x=w;
	p[n].y=h;
	sort(p+1,p+1+n,cmpx);
	for(int i=1;i<=n;i++)
		nx[i]=h-p[i].x;
	rt=Build(1,n);
	st1[0]=st2[0]=0;
	st1[1]=1;
	stv1[1]=0;
	st2[1]=1;
	stv2[1]=h;
	sn1=sn2=1;
	for(int i=2;i<=n;i++)
	{
		ans=max(ans,p[i].x+query(rt,1,i-1));
		if(p[i].y<=h/2)
		{
			while(sn1&&p[i].y>=stv1[sn1])
			{
				modify(rt,st1[sn1-1]+1,st1[sn1],stv1[sn1]-p[i].y);
				sn1--;
			}
			st1[++sn1]=i-1;
			stv1[sn1]=p[i].y;
		}
		else
		{
			while(sn2&&p[i].y<=stv2[sn2])
			{
				modify(rt,st2[sn2-1]+1,st2[sn2],p[i].y-stv2[sn2]);
				sn2--;
			}
			st2[++sn2]=i-1;
			stv2[sn2]=p[i].y;
		}
		if(stv1[sn1]==0)
			sn1--;
		if(stv2[sn2]==h)
			sn2--;
		st1[++sn1]=i;
		stv1[sn1]=0;
		st2[++sn2]=i;
		stv2[sn2]=h;
	}
	sort(p+1,p+1+n,cmpy);
	for(int i=1;i<=n;i++)
		nx[i]=w-p[i].y;
	rt=Build(1,n);
	st1[0]=st2[0]=0;
	st1[1]=1;
	stv1[1]=0;
	st2[1]=1;
	stv2[1]=w;
	sn1=sn2=1;
	for(int i=2;i<=n;i++)
	{
		ans=max(ans,p[i].y+query(rt,1,i-1));
		if(p[i].x<=w/2)
		{
			while(sn1&&p[i].x>=stv1[sn1])
			{
				modify(rt,st1[sn1-1]+1,st1[sn1],stv1[sn1]-p[i].x);
				sn1--;
			}
			st1[++sn1]=i-1;
			stv1[sn1]=p[i].x;
		}
		else
		{
			while(sn2&&p[i].x<=stv2[sn2])
			{
				modify(rt,st2[sn2-1]+1,st2[sn2],p[i].x-stv2[sn2]);
				sn2--;
			}
			st2[++sn2]=i-1;
			stv2[sn2]=p[i].x;
		}
		if(stv1[sn1]==0)
			sn1--;
		if(stv2[sn2]==w)
			sn2--;
		st1[++sn1]=i;
		stv1[sn1]=0;
		st2[++sn2]=i;
		stv2[sn2]=w;
	}
	printf("%d",ans*2);
	return 0;
}