#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if
#define Mid ((L+R)>>1)

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=300000+19;
const int oo=(1<<29)-1;
const int Top=10000000;

struct node *null;
struct node{
	node *L,*R;
	int mx;
} Nd[Top],*cur,*rt1,*rt2,*rt3,*rt4;

struct Point{
	int x,y;
	bool operator < (const Point &B) const{
		return x<B.x;
	}
} P[N];

set<int> S;
int a[N],b[N],c[N],id[N];
int W,H,n,ans;

void Modify(node *&x,int L,int R,int Qx,int Qv){
	if (x==null){
		x=cur++;
		*x=*null;
	}
	x->mx=max(x->mx,Qv);
	if (L==R) return;
	Qx<=Mid?Modify(x->L,L,Mid,Qx,Qv):Modify(x->R,Mid+1,R,Qx,Qv);
}
int Query(node *x,int L,int R,int Ql,int Qr){
	if (Ql<=L&&R<=Qr) return x->mx;
	int res=-oo;
	if (Ql<=Mid) res=max(res,Query(x->L,L,Mid,Ql,Qr));
	if (Qr>Mid) res=max(res,Query(x->R,Mid+1,R,Ql,Qr));
	return res;
}
void Init(){
	int p1=0,p2=0;
	for (int i=1;i<=n;i++)
		if (P[i].y<(H+1)/2){
			for (a[i]=p1;a[i]>0&&P[a[i]].y<=P[i].y;a[i]=a[a[i]]);
			p1=i;
		} else{
			for (a[i]=p2;a[i]>0&&P[a[i]].y>=P[i].y;a[i]=a[a[i]]);
			p2=i;
		}
	p1=n+1;p2=n+1;
	for (int i=n;i>=1;i--)
		if (P[i].y<(H+1)/2){
			for (b[i]=p1;b[i]<=n&&P[b[i]].y<=P[i].y;b[i]=b[b[i]]);
			p1=i;
		} else{
			for (b[i]=p2;b[i]<=n&&P[b[i]].y>=P[i].y;b[i]=b[b[i]]);
			p2=i;
		}
	For(i,1,n+1){
		a[i]=P[a[i]].x;
		b[i]=P[b[i]].x;
		c[i]=abs(P[i].y-(H+1)/2);
	}
}
bool cmp(int i,int j){
	return b[i]<b[j];
}
bool gao(int i,int j){
	return P[i].y<P[j].y;
}
void Work(){
	null=Nd;
	*null=(node){null,null,-oo};
	cur=Nd+1;
	rt1=rt2=rt3=rt4=null;
	P[0].x=0;
	P[n+1].x=W;
	sort(P+1,P+n+1);
	Init();
	For(i,0,n+1) ans=max(ans,2*(P[i+1].x-P[i].x+H));
	For(i,1,n+1) id[i]=i;
	sort(id+1,id+n+1,gao);
	S.clear();
	S.insert(0);
	S.insert(W);
	int t=1;
	For(j,1,n+1){
		int i=id[j];
		for (;t<=n&&P[id[t]].y<P[i].y;t++) S.insert(P[id[t]].x);
		if (P[i].y>=(H+1)/2){
			int pre=*--S.upper_bound(P[i].x);
			int suf=*S.lower_bound(P[i].x);
			ans=max(ans,2*(suf-pre+P[i].y));
		}
	}
	S.clear();
	S.insert(0);
	S.insert(W);
	t=n;
	for (int j=n;j;j--){
		int i=id[j];
		for (;t>=1&&P[id[t]].y>P[i].y;t--) S.insert(P[id[t]].x);
		if (P[i].y<(H+1)/2){
			int pre=*--S.upper_bound(P[i].x);
			int suf=*S.lower_bound(P[i].x);
			ans=max(ans,2*(suf-pre+H-P[i].y));
		}
	}
	For(i,1,n+1) id[i]=i;
	sort(id+1,id+n+1,cmp);
	For(j,1,n+1){
		int i=id[j];
		if (P[i].y>=(H+1)/2){
			ans=max(ans,2*(Query(rt3,0,W,a[i],W)+c[i]));
			ans=max(ans,2*(Query(rt4,0,W,0,a[i])+c[i]-a[i]));
			Modify(rt1,0,W,a[i],b[i]+c[i]);
			Modify(rt2,0,W,a[i],b[i]+c[i]-a[i]);
		} else{
			ans=max(ans,2*(Query(rt1,0,W,0,a[i])+c[i]-a[i]));
			ans=max(ans,2*(Query(rt2,0,W,a[i],W)+c[i]));
			Modify(rt3,0,W,a[i],b[i]+c[i]-a[i]);
			Modify(rt4,0,W,a[i],b[i]+c[i]);
		}
	}
}

int main(){
	//freopen("rect_09.txt", "r", stdin);
	//freopen("rxd.out","w",stdout);
	W=IN(),H=IN(),n=IN();
	For(i,1,n+1) P[i]=(Point){IN(),IN()};
	Work();
	swap(H,W);
	For(i,1,n+1) swap(P[i].x,P[i].y);
	Work();
	ans=max(ans,2*max(H,W)+2);
	printf("%d\n",ans);
}

Measured memory_bytes: 104448