#include <bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof a)
#define mcpy(a,b) memcpy(a,b,sizeof b)
#define lb(x) ((x)&(-(x)))
#define xx first
#define yy second
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pii pair<int,int> 
#define dalao 1000000007
#define inf 0x3f3f3f3f
#define N 300005
using namespace std;
typedef long long ll;
inline int min(int a,int b){return a<b?a:b;}
inline bool cmpx(const pii& a,const pii& b){return a.xx<b.xx||(a.xx==b.xx&&a.yy>b.yy);}
inline bool cmpy(const pii& a,const pii& b){return a.yy>b.yy;}
namespace wxh{
	int n,tp;
	pii a[N],s[N];
	inline int calc(int R,int C){
		int ans=tp=0;
		sort(a+1,a+1+n,cmpx);
		int L=0;
		for(int i=1;i<=n;){
			int j=i,flag=0;
			while(j<=n&&a[j].xx==a[i].xx){
				ans=max(ans,2*C+2*(a[j].xx-L));
				if(a[j].yy>0&&a[j].yy<C)flag=1;
				j++;
			}
			if(flag)L=a[i].xx;
			i=j;
		}
		for(int i=1;i<=n;i++){
			if(a[i+1].xx==a[i].xx)continue;
			while(tp&&s[tp].yy>=a[i].yy){
				if(s[tp].yy>a[i].yy)
					ans=max(ans,2*(a[i].xx-s[tp-1].xx)+2*s[tp].yy);//,cout<<s[tp-1].xx<<" "<<s[tp].yy<<" "<<a[i].xx<<endl;
				tp--;
			}
			s[++tp]=a[i];
		}
		for(int i=0;i<=tp;i++)ans=max(ans,2*(R-s[i].xx)+2*s[i+1].yy);
		return ans;
	}
}
int R,C,n,m,ta,tb,mi[N<<2],ans,s[21],tp;
pii a[N],b[N],sa[N],sb[N];
inline void modify(int x,int l,int r,int p,int v){
	tp=0;
	while(1){
		if(l==r){mi[x]=v;break;}
		int mid=l+r>>1;s[++tp]=x;
		if(p<=mid)x<<=1,r=mid;else x=x<<1|1,l=mid+1;
	}
	while(tp)mi[s[tp]]=min(mi[s[tp]<<1],mi[s[tp]<<1|1]),tp--;
}
inline int ask(int x,int l,int r,int L,int R){
	if(l>r)return inf;
	if(l==L&&r==R)return mi[x];
	int mid=L+R>>1;
	if(r<=mid)return ask(x<<1,l,r,L,mid);
	else if(l>mid)return ask(x<<1|1,l,r,mid+1,R);
	return min(ask(x<<1,l,mid,L,mid),ask(x<<1|1,mid+1,r,mid+1,R));
}
inline int lower_bound(pii* a,int n,pii v){
	if(a[n].xx<v.xx)return n+1;
	int l=1,r=n;
	while(l<r){
		int mid=l+r>>1;
		if(a[mid].xx<v.xx)l=mid+1;else r=mid;
	}
	return r;
}
inline int upper_bound(pii* a,int n,pii v){
	if(a[n].xx<=v.xx)return n+1;
	int l=1,r=n;
	while(l<r){
		int mid=l+r>>1;
		if(a[mid].xx<=v.xx)l=mid+1;else r=mid;
	}
	return r;
}
inline void calc(int l1,int r1,int l2,int r2){
//	for(int i=l1;i<=r1;i++)printf("[%d, %d] ",a[i].xx,a[i].yy);puts("");
//	for(int i=l2;i<=r2;i++)printf("[%d, %d] ",a[i].xx,a[i].yy);puts("\n");
	int L=r2-l2+1;
	for(int i=1;i<=L;i++)b[i]=a[l2+i-1];
	for(int i=0;i<=(L<<2);i++)mi[i]=inf;
	ta=tb=0;
/*	sb[tb+1]=mp(sb[tb].xx+1,sb[tb].yy-1);
	m=lg[tb];
	for(int i=1;i<=tb;i++)f[0][i]=sb[i].xx+sb[i+1].yy;//,cout<<sb[i].xx<<" "<<sb[i+1].yy<<endl;
	for(int j=1;j<=m;j++)for(int i=1;i<=n;i++)f[j][i]=min(f[j-1][i],f[j-1][min(tb,i+(1<<j-1))]);*/
//	sa[0]=mp(-1,0);
	for(int i=l1,j=0;i<=r1;i++){
		while(j<L&&b[j+1].xx<a[i].xx){
			j++;
			while(tb&&sb[tb].yy<=b[j].yy)tb--;
			sb[++tb]=b[j];
			if(tb>1)modify(1,1,L,tb-1,b[j].yy+sb[tb-1].xx);//,cout<<tb-1<<" "<<b[j].yy+sb[tb-1].xx<<endl;
		}
		while(ta&&sa[ta].yy>=a[i].yy){
			if(sa[ta].xx<a[i].xx&&sa[ta].yy>a[i].yy){
//				cout<<a[i].xx<<" "<<a[i].yy<<" "<<sa[ta].xx<<" "<<sa[ta].yy<<endl;
				int A=upper_bound(sb,tb,sa[ta-1]),B=lower_bound(sb,tb,a[i])-1;
//				cout<<A<<" "<<B<<" "<<tb<<endl;
				if(A<=B){
//					cout<<A<<" "<<B-1<<" "<<ask(1,A,B-1,1,L)<<endl;
					ans=max(ans,2*(a[i].xx+sa[ta].yy)-2*ask(1,A,B-1,1,L));
					ans=max(ans,2*(a[i].xx+sa[ta].yy)-2*(sa[ta-1].xx+sb[A].yy));
//					cout<<ans<<endl;
//					cout<<sa[ta-1].xx<<" "<<sb[A].yy<<" "<<a[i].xx<<" "<<sa[ta].yy<<endl;
				}
			}
			ta--;
		}
		sa[++ta]=a[i];
	}
}
inline void solve(int l,int r){
	int mid=0;
	for(int i=l;i<=r;i++)if(a[i].yy>(C>>1)&&(i==n||a[i+1].yy<=(C>>1))){mid=i;break;}
	sort(a+l,a+mid+1,cmpx),sort(a+mid+1,a+r+1);
//	cout<<l<<" "<<mid<<" "<<r<<endl;
	calc(l,mid,mid+1,r);
	for(int i=l;i<=r;i++)a[i].xx=R-a[i].xx;
	reverse(a+l,a+mid+1),reverse(a+mid+1,a+r+1);
	calc(l,mid,mid+1,r);
	for(int i=l;i<=r;i++)a[i].xx=R-a[i].xx;
	reverse(a+l,a+mid+1),reverse(a+mid+1,a+r+1);
	
	for(int i=l;i<=r;i++)a[i].yy=C-a[i].yy;
	
	calc(mid+1,r,l,mid);
	for(int i=l;i<=r;i++)a[i].xx=R-a[i].xx;
	reverse(a+l,a+mid+1),reverse(a+mid+1,a+r+1);
	calc(mid+1,r,l,mid);
	for(int i=l;i<=r;i++)a[i].xx=R-a[i].xx;
	reverse(a+l,a+mid+1),reverse(a+mid+1,a+r+1);
	
	for(int i=l;i<=r;i++)a[i].yy=C-a[i].yy;
}
int main(){
//	freopen("data.txt","r",stdin);
//	freopen("rect_03.txt","r",stdin);
	int cc=0;
	while(scanf("%d%d%d",&R,&C,&n)==3){
		ans=0;
		for(int i=1;i<=n;i++)scanf("%d%d",&a[i].xx,&a[i].yy);
//		if(++cc==3250){cout<<R<<" "<<C<<" "<<n<<endl;for(int i=1;i<=n;i++)printf("%d %d\n",a[i].xx,a[i].yy);}
		sort(a+1,a+1+n,cmpy);
		solve(1,n);
		for(int i=1;i<=n;i++)swap(a[i].xx,a[i].yy);
		swap(R,C);
		sort(a+1,a+1+n,cmpy);
		solve(1,n);
		wxh::n=n;
		for(int i=1;i<=n;i++)wxh::a[i]=a[i];
		ans=max(ans,wxh::calc(R,C));
		for(int i=1;i<=n;i++)wxh::a[i]=mp(a[i].yy,R-a[i].xx);
		ans=max(ans,wxh::calc(C,R));
		for(int i=1;i<=n;i++)wxh::a[i]=mp(R-a[i].xx,C-a[i].yy);
		ans=max(ans,wxh::calc(R,C));
		for(int i=1;i<=n;i++)wxh::a[i]=mp(C-a[i].yy,a[i].xx);
		ans=max(ans,wxh::calc(C,R));
//		printf("Case #%d: %d\n",++cc,ans);
		printf("%d\n",ans);
	}
	return 0;
}
/*
6 6 9
3 4
1 1
0 5
2 1
5 5
4 3
2 6
3 2
1 6

10 10 4
1 6
4 1
6 9
9 4
*/

Measured memory_bytes: 17536