#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#define md double
#define LL long long
using namespace std;
const int N=6e5,M=N<<2;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
struct P{ int x,y; }p[N],st1[N],st2[N];
inline bool cmpx(const P &a,const P &b) { return a.x<b.x; }
int x[N],ans;
int mx[M],tag[M];
#define lc (i<<1)
#define rc (lc|1)
inline void build(int i,int l,int r) {
	mx[i]=-1<<30,tag[i]=0;
	if (l!=r) {
		int mid=(l+r)>>1;
		build(lc,l,mid);build(rc,mid+1,r);
	}
}
inline void modify(int i,int l,int r,int L,int R,int d) {
	if (L<=l&&r<=R) tag[i]+=d,mx[i]+=d;
	else {
		int mid=(l+r)>>1;
		if (tag[i]) {
			mx[lc]+=tag[i],tag[lc]+=tag[i];
			mx[rc]+=tag[i],tag[rc]+=tag[i];
			tag[i]=0;
		}
		if (L<=mid) modify(lc,l,mid,L,R,d);
		if (mid<R) modify(rc,mid+1,r,L,R,d);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
inline void init(int i,int l,int r,int k,int d) {
	if (l==r) mx[i]=d;
	else {
		int mid=(l+r)>>1;
		k<=mid?init(lc,l,mid,k,d):init(rc,mid+1,r,k,d);
		mx[i]=max(mx[lc],mx[rc]);
	}
}
inline void solve(int n,int m,int T) {
	int i,len=T,l1,l2,a,b,e,l,r,mid;P *st;sort(p+1,p+1+T,cmpx);
	for (i=1;i<=T;i++) x[i]=p[i].x;p[++T]=(P){n,m>>1};
	x[++len]=0,x[++len]=n;
	sort(x+1,x+1+len);len=unique(x+1,x+1+len)-x-1;
	build(1,1,len);
	init(1,1,len,1,m);
	st1[l1=1]=st2[l2=1]=(P){1,m>>1};
	for (i=1;i<=T;i++) {
		int &top=p[i].y<=m>>1?(st=st1,l1):(st=st2,l2);
		a=p[i].x,b=abs(p[i].y-(m>>1));
		for (l=1,r=len;l!=r;a<=x[mid=(l+r)>>1]?r=mid:l=mid+1);a=l;e=a;
		ans=max(ans,x[a]+mx[1]);
		init(1,1,len,a,m-x[a]);
		while (top&&b<st[top].y) {
			if (st[top].x!=e) modify(1,1,len,st[top].x,e-1,b-st[top].y);
			e=st[top--].x;
		}
		if (e!=a) st[++top]=(P){e,b};
		st[++top]=(P){a,m>>1};
		if (p[i].y>m>>1) st1[++l1]=(P){a,m>>1};
		else st2[++l2]=(P){a,m>>1};
	}
}
int main()
{
	int n=gi()<<1,m=gi()<<1,T=gi(),i;
	for (i=1;i<=T;i++) p[i].x=gi()<<1,p[i].y=gi()<<1;
	solve(n,m,T);
	for (i=1;i<=T;i++) swap(p[i].x,p[i].y);
	solve(m,n,T);
	printf("%d\n",ans);
	return 0;
}
