#include<bits/stdc++.h>
using namespace std;
const int maxn=6e5+7;
typedef pair<int,int> pi;
vector<int> all;
vector<pi> point;
void mkuni(vector<int>& a){
	sort(a.begin(),a.end());
	a.erase(unique(a.begin(),a.end()),a.end());
}
inline int getid(int x){
	return lower_bound(all.begin(),all.end(),x)-all.begin();
}
int w,h,n,sz;
int ans;
namespace sgt{
int sum[maxn<<2],lz[maxn<<2];
#define lson o<<1
#define rson o<<1|1
#define Lson L,mid,lson
#define Rson mid+1,R,rson
inline void pushdown(int o){
	if(lz[o]){
		sum[lson]+=lz[o];
		sum[rson]+=lz[o];
		lz[lson]+=lz[o];
		lz[rson]+=lz[o];
		lz[o]=0;
	}
}
inline void pushup(int o){
	sum[o]=max(sum[lson],sum[rson]);
}
void update(int l,int r,int val,int L=1,int R=sz,int o=1){
	if(l<=L&&r>=R)
	{
		sum[o]+=val;
		lz[o]+=val;
		return;
	}
	pushdown(o);
	int mid=L+R>>1;
	if(l<=mid) update(l,r,val,Lson);
	if(r>mid) update(l,r,val,Rson);
	pushup(o);
}
int query(int l,int r,int L=1,int R=sz,int o=1){
	if(l<=L&&r>=R)
		return sum[o];
	int mid=L+R>>1;
	pushdown(o);
	int ret=0;
	if(l<=mid) ret=max(ret,query(l,r,Lson));
	if(r>mid) ret=max(ret,query(l,r,Rson));
	return ret;
}
};
vector<int> pc[maxn];
int mx[maxn],mi[maxn];
void solve(){
	memset(sgt::sum,0,sizeof(sgt::sum));
	memset(sgt::lz,0,sizeof(sgt::lz));
	stack<int> lw,up;
	int var=getid(h/2);
	for(int i=0;i<=sz;i++) pc[i].clear();
	for(int i=0;i<point.size();i++){
		int x=point[i].first,y=point[i].second;
		pc[x].push_back(y);
	}
	for(int i=2;i<sz;i++){
		if(all[i]>w) break;
		sgt::update(i-1,i-1,h);
		sgt::update(1,i-1,all[i]-all[i-1]);
		ans=max(ans,sgt::query(1,i-1));
		//cerr<<i<<"="<<all[i]<<":"<<sgt::query(1,i-1)<<endl;
		//cout<<i<<":::"<<all[i]<<endl;
		/*for(int j=1;j<=i;j++){
			cout<<j<<":"<<sgt::query(j,j)<<endl;
		}*/
		sgt::update(i-1,i-1,-h);
		mx[i]=getid(h),mi[i]=getid(0);
		for(auto u:pc[i]){
			if(u>=var) mx[i]=min(mx[i],u);
			if(u<=var) mi[i]=max(mi[i],u);
		}
		while(!lw.empty()&&mi[lw.top()]<=mi[i]){
			int id=lw.top();
			lw.pop();
			int val=all[var]-all[mi[id]];
			int pp;
			if(lw.size()) pp=lw.top();
			else pp=1;
			//cout<<"minus:"<<pp<<","<<id<<":"<<-val<<endl;
			sgt::update(pp,id-1,-val);
		}
		sgt::update(lw.size()?lw.top():1,i-1,all[var]-all[mi[i]]);
		lw.push(i);
		while(!up.empty()&&mx[up.top()]>=mx[i]){
			int id=up.top();
			up.pop();
			int val=all[mx[id]]-all[var];
			int pp;
			if(up.size()) pp=up.top();
			else pp=1;
			//cout<<"minus:"<<pp<<","<<id<<":"<<-val<<endl;
			sgt::update(pp,id-1,-val);
		}
		sgt::update(up.size()?up.top():1,i-1,all[mx[i]]-all[var]);
		up.push(i);
	}
}
int main()
{
	cin>>w>>h>>n;
	all.emplace_back(-1);
	all.emplace_back(h);
	all.emplace_back(w);
	all.emplace_back(0);
	all.emplace_back(w/2);
	all.emplace_back(h/2);
	for(int i=1,x,y;i<=n;i++){
		cin>>x>>y;
		point.emplace_back(x,y);
		all.emplace_back(x);
		all.emplace_back(y);
	}
	point.emplace_back(0,0);
	point.emplace_back(0,h);
	point.emplace_back(w,0);
	point.emplace_back(w,h);
	mkuni(all);
	for(int i=0;i<point.size();i++){
		point[i].first=getid(point[i].first);
		point[i].second=getid(point[i].second);
	}
	sz=all.size();
	solve();
	for(int i=0;i<point.size();i++) swap(point[i].first,point[i].second);
	swap(h,w);
	solve();
	cout<<ans*2<<endl;
}

Measured memory_bytes: 64348