// Original C++ solution (slower):
//from Kuugo

#include<bits/stdc++.h>

using namespace std;

#define N 1111116

 

int w,h,n,l[N],r[N],f[N],g[N],ans;

 

struct node{int x,y;}a[N];

vector<node> ql,qr;

bool cmp(node a,node b){return a.y<b.y;}

 

void build(int t,int x,int y){

	l[t]=x;r[t]=y;f[t]=0;g[t]=0;

	if (x==y){f[t]=w-a[x].y;return;}

	build(2*t,x,(x+y)/2);

	build(2*t+1,(x+y)/2+1,y);

	f[t]=max(f[2*t],f[2*t+1]);

}

 

void modify(int t,int x,int y,int z){

	if (x<=l[t]&&y>=r[t]) {f[t]+=z;g[t]+=z;return;};

	if (x<=r[2*t]) modify(2*t,x,y,z);

	if (y>=l[2*t+1]) modify(2*t+1,x,y,z);

	f[t]=max(f[2*t],f[2*t+1])+g[t];

}

 

void solve(){

	sort(a+1,a+n+1,cmp);

	build(1,0,n);

	ql.clear();ql.push_back((node){0,-1});ql.push_back((node){0,0});

	qr.clear();qr.push_back((node){w,-1});qr.push_back((node){w,0});

	for (int i=1;i<=n;i++){

		ans=max(ans,(f[1]+a[i].y)*2);

		if (a[i].x<=w/2){

			for (int j=ql.size()-1;j&&ql[j].x<=a[i].x;ql.pop_back(),j--)

				modify(1,ql[j-1].y+1,ql[j].y,ql[j].x-a[i].x);

			ql.push_back((node){a[i].x,i-1});

		}

		else {

			for (int j=qr.size()-1;j&&qr[j].x>=a[i].x;qr.pop_back(),j--)

				modify(1,qr[j-1].y+1,qr[j].y,a[i].x-qr[j].x);

			qr.push_back((node){a[i].x,i-1});

		}

		ql.push_back((node){0,i});

		qr.push_back((node){w,i});

	}

	ans=max(ans,(f[1]+h)*2);

}

 

int read(){

	int x=0,f=1;char ch=getchar();

	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-f;

	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';

	return x*f;

}

 

int main(){

	w=read();h=read();n=read();

	for (int i=1;i<=n;i++) a[i].x=read(),a[i].y=read();

	solve();

	for (int i=1;i<=n;i++) swap(a[i].x,a[i].y);

	swap(h,w);solve();

	printf("%d\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<algorithm>

#define ls p<<1,l,m

#define rs p<<1|1,m+1,r

using namespace std;

const int N=3e5+5,P=4*N;

int nn,mm,n,i,x,y,k;

struct arr{int x,y;}a[N];

bool operator < (arr A,arr B){return A.x<B.x;}

int read(){

	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());

	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;

}

int tl,tr;

struct stack{int x,k;}ql[N],qr[N];

int mx[P],ad[P];

void change(int p,int l,int r){

	if (x<=l&&r<=y){ad[p]+=k;mx[p]+=k;return;}

	int m=l+r>>1;

	if (x<=m) change(ls);if (y>m) change(rs);

	mx[p]=ad[p]+max(mx[p<<1],mx[p<<1|1]);

}

void build(int p,int l,int r){

	if (l==r){mx[p]=mm-a[l].x;return;}

	int m=l+r>>1;build(ls);build(rs);

	ad[p]=0;mx[p]=ad[p]+max(mx[p<<1],mx[p<<1|1]);

}

int work(){

	sort(a+1,a+n+1);int res=0;

	tl=1;ql[0].x=-1;ql[1]=(stack){0,0};

	tr=1;qr[0].x=-1;qr[1]=(stack){0,mm};

	build(1,0,n);int mid=mm>>1;

	for (i=1;i<=n;i++){

		res=max(res,(mx[1]+a[i].x)*2);

		if (a[i].y<=mid){

			for (;tl&&a[i].y>ql[tl].k;tl--)

				x=ql[tl-1].x+1,y=ql[tl].x,

				k=ql[tl].k-a[i].y,change(1,0,n);

			ql[++tl]=(stack){i-1,a[i].y};

		}

		else{

			for (;tr&&a[i].y<qr[tr].k;tr--)

				x=qr[tr-1].x+1,y=qr[tr].x,

				k=a[i].y-qr[tr].k,change(1,0,n);

			qr[++tr]=(stack){i-1,a[i].y};

		}

		ql[++tl]=(stack){i,0};qr[++tr]=(stack){i,mm};

	}

	return max(res,(mx[1]+nn)*2);

}

int main(){

	nn=read();mm=read();

	for (n=read(),i=1;i<=n;i++)

		a[i]=(arr){read(),read()};

	int ans=work();swap(nn,mm);

	for (i=1;i<=n;i++) swap(a[i].x,a[i].y);

	ans=max(ans,work());

	printf("%d",ans);

}

// Fastest known solution for this problem: