#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
const int INF = 4e8+10;
const int N = 300010;
int W,H,n,ans,tailL,tailR,f[N],L[N],R[N];
PII p[N],q[N];

struct Node {
	int l,r,mx,tag;
}t[N*4];
void build(int x,int l,int r){
	t[x].l=l,t[x].r=r;
	t[x].mx = -INF;
	t[x].tag = 0;
	if(l==r) return ;
	int mid = (l+r)/2;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
}
inline void push(int x){
	if(t[x].tag<-INF) t[x].tag = -INF;
	t[x].mx+=t[x].tag;
	if(t[x].mx<-INF) t[x].mx = -INF;
	if(t[x].l<t[x].r) {
		t[x*2].tag += t[x].tag;
		t[x*2+1].tag += t[x].tag;
	}
	t[x].tag = 0;
}
void add(int x,int l,int r,int aug){
	if(t[x].l==l && t[x].r==r) {
		t[x].tag+=aug;
		return ;
	}
	push(x);
	int mid = (t[x].l+t[x].r)/2;
	if(r<=mid) add(x*2,l,r,aug) ;
	else if(l>mid) add(x*2+1,l,r,aug);
	else add(x*2,l,mid,aug),add(x*2+1,mid+1,r,aug);
	push(x*2),push(x*2+1);
	t[x].mx = max(t[x*2].mx,t[x*2+1].mx);
}
int find(int x,int l,int r){
	push(x);
	if(t[x].l==l && t[x].r==r) return t[x].mx;
	push(x*2),push(x*2+1);
	int mid = (t[x].l+t[x].r)/2;
	if(r<=mid) return find(x*2,l,r);
	else if(l>mid) return find(x*2+1,l,r);
	else return max(find(x*2,l,mid) ,find(x*2+1,mid+1,r));
}
void solve(int l,int r,int left,int right){
	//cout<<l<<' '<<r<<' '<<left<<' '<<right<<endl;
	int mid = (l+r)/2;
	if(l==r){
		if(p[l].Y>0) ans = max(ans,2*(right-left+p[l].Y));
		if(p[l].Y<H) ans = max(ans,2*(right-left+H-p[l].Y)); 
		if(p[l].X>left) ans =max(ans,2*(p[l].X-left+H));
		if(p[l].X<right) ans =max(ans,2*(right-p[l].X+H));
		return ;
	}
	int tmp = p[mid].X;
	solve(l,mid,left,p[mid+1].X);
	solve(mid+1,r,tmp,right);
	int cnt = 1;
	f[0]=1;
	q[1] = mp(p[mid].X,0);
	for(int i = l, j = mid+1;i <= mid || j <= r;){
		if(i <= mid && (j > r || p[j].Y > p[i].Y)){
			q[++cnt] = p[i];
			f[i] = cnt; 
			i++;
		} else {
			q[++cnt] = p[j];
			f[j] = cnt;
			j++;
		}
	}
	build(1,1,r-l+2);
	add(1,1,1,INF+right-left);
	tailL = tailR = 1;
	L[1] = R[1] = 0;
	
	for(int i = l, j = mid+1;i <= mid || j <= r;){
		if(i <= mid && (j > r || p[j].Y > p[i].Y)){
			ans = max(ans,2*(find(1,1,r-l+2)+p[i].Y));
			add(1,f[i],f[i],INF+right-left-p[i].Y);
			add(1,f[L[tailL]],f[i]-1,-p[i].X+left);
			while(tailL>1 && p[i].X>p[L[tailL]].X) {
				add(1,f[L[tailL-1]],f[L[tailL]]-1,-p[i].X+p[L[tailL]].X);
				add(1,f[L[tailL]],f[L[tailL]],-INF);
				tailL--; 
			}
			L[++tailL] = i;
			i++;
		} else {
			ans = max(ans,2*(find(1,1,r-l+2)+p[j].Y));
			add(1,f[j],f[j],INF+right-left-p[j].Y);
			add(1,f[R[tailR]],f[j]-1,-right+p[j].X);
			while(tailR>1 && p[j].X<p[R[tailR]].X) {
				add(1,f[R[tailR-1]],f[R[tailR]]-1,p[j].X-p[R[tailR]].X);
				add(1,f[R[tailR]],f[R[tailR]],-INF);
				tailR--; 
			}
			R[++tailR] = j;
			j++;
		}
	}
	ans = max(ans,2*(find(1,1,r-l+2)+H));
	
	//  end???
	for(int i=l;i<=r;i++) p[i]=q[i-l+2];
}
inline int read(){
	int ans=0;
	char last=' ',ch=getchar();
	
	while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();

	return ans;
}
int main(){
	//scanf("%d%d%d",&W,&H,&n);
	W = read(), H = read(), n = read();
	for(int i=1;i<=n;i++) p[i].X = read(), p[i].Y = read();//scanf("%d%d",&p[i].X,&p[i].Y);
	sort(p+1,p+1+n);
	solve(1,n,0,W);
	//for(int i=1;i<=n;i++) cout<<p[i].X<<' '<<p[i].Y<<endl;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 23168