#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 300010;
const int maxm = maxn*30;
const int N = 1e8;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int H,W,n;

PII A[maxn],Q1[maxn],Q2[maxn];
int top1,top2;

int rt,ans;
int mx[maxm],bj[maxm],ls[maxm],rs[maxm],sz;

void update(int x,int y){
	mx[x]+=y;bj[x]+=y;
}

void pushup(int x){
	mx[x]=max(mx[ls[x]],mx[rs[x]]);
}

void pushdown(int x){
	int &v=bj[x];
	if(ls[x])update(ls[x],v);
	if(rs[x])update(rs[x],v);
	v=0;
}

void add(int &x,int l,int r,int p,int t){
	if(!x)x=++sz,mx[x]=-MAX,bj[x]=0;
	if(l==r){
		mx[x]=t;
		return;
	}
	int M=l+r>>1;pushdown(x);
	if(p<=M)add(ls[x],l,M,p,t);else add(rs[x],M+1,r,p,t);
	pushup(x);
}

void update(int x,int l,int r,int L,int R,int v){
	if(!x||L>R)return;
	if(L<=l&&r<=R){
		update(x,v);
		return;
	}
	int M=l+r>>1;pushdown(x);
	if(L<=M)update(ls[x],l,M,L,R,v);if(R>M)update(rs[x],M+1,r,L,R,v);
	pushup(x);
}

void solve(){
	sort(A+1,A+n+1);
	int M1=H>>1,M2=H+1>>1;
	rt=0;mx[0]=-MAX;REP(i,1,sz)ls[i]=rs[i]=0;sz=0;
	Q1[top1=1]=MP(M1,0);Q2[top2=1]=MP(M2,0);
	add(rt,0,N,0,H);
	
	REP(i,1,n){
		ans=max(ans,A[i].fi+mx[rt]);
//		cout<<ans<<endl;
		if(A[i].se<=M1){
			int lst=A[i].fi,cur=0;
			while(top1&&Q1[top1].fi<A[i].se){
				update(rt,0,N,Q1[top1].se,lst-1,-A[i].se+cur);
				cur=Q1[top1].fi;lst=Q1[top1].se;
				top1--;
			}
			update(rt,0,N,Q1[top1].se,lst-1,-A[i].se+cur);
			Q1[++top1]=MP(A[i].se,A[i].fi);
		}
		if(A[i].se>=M2){
			int lst=A[i].fi,cur=H;
			while(top2&&Q2[top2].fi>A[i].se){
				update(rt,0,N,Q2[top2].se,lst-1,A[i].se-cur);
				cur=Q2[top2].fi;lst=Q2[top2].se;
				top2--;
			} 
			update(rt,0,N,Q2[top2].se,lst-1,A[i].se-cur);
			Q2[++top2]=MP(A[i].se,A[i].fi);
		}
		add(rt,0,N,A[i].fi,H-A[i].fi);
	}
	ans=max(ans,W+mx[rt]);
}

void Work(){
	solve();
	swap(H,W);REP(i,1,n)swap(A[i].fi,A[i].se);
	solve();
	iout(ans*2);
}

void Init(){
	 read(W,H,n);
	 REP(i,1,n)read(A[i].fi,A[i].se);
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 57856