#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define maxd 998244353
#define eps 1e-8
struct node{int x,y;}p[300300];
bool operator <(node p,node q) {return p.x<q.x;}
int w,h,ans=0,n,seg[1200200],tag[1200200],sta[2][300300];

int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

void pushdown(int id)
{
	if (tag[id])
	{
		seg[id<<1]+=tag[id];
		tag[id<<1]+=tag[id];
		seg[id<<1|1]+=tag[id];
		tag[id<<1|1]+=tag[id];
		tag[id]=0;
	}
}

void build(int id,int l,int r)
{
	seg[id]=h<<1;tag[id]=0;
	if (l==r) return;
	int mid=(l+r)>>1;
	build(id<<1,l,mid);build(id<<1|1,mid+1,r);
}

void modify(int id,int l,int r,int ql,int qr,int val)
{
	if (ql>qr) return;
	if ((l>=ql) && (r<=qr))
	{
		seg[id]+=val;tag[id]+=val;
		return;
	}
	pushdown(id);
	int mid=(l+r)>>1;
	if (ql<=mid) modify(id<<1,l,mid,ql,qr,val);
	if (qr>mid) modify(id<<1|1,mid+1,r,ql,qr,val);
	seg[id]=max(seg[id<<1],seg[id<<1|1]);
}

void solve()
{
	sort(p+1,p+1+n);
	build(1,1,n);
	int tp0=0,tp1=0;
	sta[0][0]=sta[1][0]=1;
	rep(i,2,n)
	{
		modify(1,1,n,1,i-1,(p[i].x-p[i-1].x)<<1);
		ans=max(ans,seg[1]);
		if (p[i].y>=h/2)
		{
			modify(1,1,n,sta[0][tp0],i-1,(p[i].y-h)<<1);
			while ((tp0) && (p[sta[0][tp0]].y>=p[i].y))
			{
				int delta=p[i].y-p[sta[0][tp0]].y;
				modify(1,1,n,sta[0][tp0-1],sta[0][tp0]-1,delta*2);
				tp0--;
			}
			sta[0][++tp0]=i;
		}
		else
		{
			modify(1,1,n,sta[1][tp1],i-1,-(p[i].y<<1));
			while ((tp1) && (p[sta[1][tp1]].y<=p[i].y))
			{
				int delta=p[sta[1][tp1]].y-p[i].y;
				modify(1,1,n,sta[1][tp1-1],sta[1][tp1]-1,delta*2);
				tp1--;
			}
			sta[1][++tp1]=i;
		}
	}
}

int main()
{
	w=read();h=read();n=read();
	rep(i,1,n) {p[i].x=read();p[i].y=read();}
	p[++n].x=w;p[++n].y=h;
	p[++n].x=0;p[++n].y=0;
	solve();
	swap(w,h);
	rep(i,1,n) swap(p[i].x,p[i].y);
	solve();
	printf("%d",ans);
	return 0;
}
