// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

#define lson (t<<1)
#define rson ((t<<1)|1)
struct SGT
{
	struct segment
	{
		int l,r,mx,delta;
	}seg[1050111];
	void pushdown(int t)
	{
		seg[lson].delta+=seg[t].delta;seg[rson].delta+=seg[t].delta;
		seg[lson].mx+=seg[t].delta;seg[rson].mx+=seg[t].delta;
		seg[t].delta=0;
	}
	void build(int l,int r,int t=1)
	{
		seg[t].l=l;seg[t].r=r;seg[t].mx=-inf;seg[t].delta=0;
		if(l==r)return;
		int mid=(l+r)>>1;
		build(l,mid,lson);build(mid+1,r,rson);
	}
	void add(int l,int r,int v,int t=1)
	{
		if(l>r)return;
		if(seg[t].l==l&&seg[t].r==r)
		{
			seg[t].delta+=v;seg[t].mx+=v;
			return;
		}
		pushdown(t);
		int mid=(seg[t].l+seg[t].r)>>1;
		if(r<=mid)add(l,r,v,lson);
		else if(l>mid)add(l,r,v,rson);
		else
		{
			add(l,mid,v,lson);
			add(mid+1,r,v,rson);
		}
		seg[t].mx=max(seg[lson].mx,seg[rson].mx);
	}
	void set(int p,int v,int t=1)
	{
		if(seg[t].l==seg[t].r)
		{
			seg[t].mx=v;
			return;
		}
		pushdown(t);
		int mid=(seg[t].l+seg[t].r)>>1;
		if(p<=mid)set(p,v,lson);
		else set(p,v,rson);
		seg[t].mx=max(seg[lson].mx,seg[rson].mx);
	}
	int query()
	{
		return seg[1].mx;
	}
}m1;

bool cmp(pii a,pii b){return mp(a.ss,a.ff)<mp(b.ss,b.ff);}
int w,h,n,ans;
pii a[300111];
pair<pii,int> stk1[300111],stk2[300111];

void solve()
{
	m1.build(1,n);
	sort(a+1,a+n+1,cmp);
	int t1=0,t2=0;
	for(int i=1;i<=n;i++)
	{
		if(i>1)ans=max(ans,m1.query()+a[i].ss);
		if(a[i].ff<=w/2)
		{
			int c=w/2-a[i].ff,low=-1;
			while(t1&&c<stk1[t1].ss)
			{
				m1.add(stk1[t1].ff.ff,stk1[t1].ff.ss,-(stk1[t1].ss-c));
				low=stk1[t1].ff.ff;
				t1--;
			}
			if(low>-1)stk1[++t1]=mp(mp(low,i-1),c);
		}
		if(a[i].ff>=w/2)
		{
			int c=a[i].ff-w/2,low=-1;
			while(t2&&c<stk2[t2].ss)
			{
				m1.add(stk2[t2].ff.ff,stk2[t2].ff.ss,-(stk2[t2].ss-c));
				low=stk2[t2].ff.ff;
				t2--;
			}
			if(low>-1)stk2[++t2]=mp(mp(low,i-1),c);
		}
		stk1[++t1]=mp(mp(i,i),w/2);
		stk2[++t2]=mp(mp(i,i),w-w/2);
		m1.set(i,w-a[i].ss);
	}
}
int main()
{
	get3(w,h,n);
	for(int i=1;i<=n;i++)get2(a[i].ff,a[i].ss);
	a[++n]=mp(0,0);a[++n]=mp(0,h);a[++n]=mp(w,0);a[++n]=mp(w,h);
	solve();
	swap(w,h);for(int i=1;i<=n;i++)swap(a[i].ff,a[i].ss);
	solve();
	printendl(ans*2);
	return 0;
}

Measured memory_bytes: 25472