#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<pair<ll,ll>,ll> P;

ll w,h,n;
bool isup[333333];

ll nyan(vector<pair<ll,pair<ll,ll>>> nowA, vector<pair<ll,pair<ll,ll>>> nowB){
	ll ret = 0;
	
	ll lineA = -1,lineB = -1;
	deque<pair<ll,ll>> deq;
	for(ll i = 0;i < nowA.size();i++){
		ll nowU = nowA[i].SE.FI;
		ll nowD = nowA[i].SE.SE;
		ll nowL = nowA[i].FI;
		while((ll)lineA < (ll)nowB.size() - 1 && nowB[lineA+1].SE.FI >= nowU && nowB[lineA+1].SE.SE <= nowD)lineA++;
		if(lineA != -1){
			ret = max(ret,nowU - nowD + nowB[lineA].FI - nowL);
		}
		lineB = max(lineA,lineB);
		while((ll)lineB < (ll)nowB.size() - 1 && nowB[lineB+1].SE.SE <= nowD){
			while(!deq.empty() && deq.rbegin()->FI < nowB[lineB+1].SE.FI + nowB[lineB+1].FI){
				deq.pop_back();
			}
			deq.push_back(MP(nowB[lineB+1].SE.FI + nowB[lineB+1].FI,lineB+1));
			lineB++;
		}
		while(!deq.empty() && deq[0].SE <= lineA)deq.pop_front();
		if(deq.size())ret = max(ret,deq[0].FI - nowL - nowD);
		//cout << "NYAN " <<  lineA << " " << lineB << endl;
	}
	//cout << "RET " << ret << endl;
	return ret;
}

ll seica(vector<P> v1, vector<P> v2, ll U, ll D, ll L, ll R){
	ll ret = 0;
	//cout << v1.size() << " " << v2.size() << " " << U << ' ' << D << " " << L << " " << R << endl;
	vector<P> vv1;
	vector<P> vv2;
	vector<P> vv3;
	vector<P> vv4;
	ll mid;
	REP(i,v2.size()){
		if(i < v2.size() / 2){
			isup[v2[i].SE] = 0;
			vv2.PB(v2[i]);
		}
		else {
			isup[v2[i].SE] = 1;
			vv4.PB(v2[i]);
		}
		if(i == v2.size()/2)mid = v2[i].FI.FI;
	}
	REP(i,v1.size()){
		if(isup[v1[i].SE])vv3.PB(v1[i]);
		else vv1.PB(v1[i]);
	}
	if(vv1.size() > 1)ret = max(ret,seica(vv1, vv2, mid, D, L, R));
	if(vv3.size() > 1)ret = max(ret,seica(vv3, vv4, U, mid, L, R));
	
	vv1.clear();
	vv3.clear();
	REP(i,v1.size()){
		if(v1[i].FI.FI < (L + R) / 2)vv1.PB(v1[i]);
		else vv3.PB(v1[i]);
	}
	
	vector<pair<ll,pair<ll,ll>>> nowA;
	vector<pair<ll,pair<ll,ll>>> nowB;
	ll uu = U,dd = D;
	for(int i = vv1.size() - 1;i >= 0;i--){
		nowA.PB(MP(vv1[i].FI.FI,MP(uu,dd)));
		if(vv1[i].FI.SE > mid)uu = min(uu,vv1[i].FI.SE);
		else if(vv1[i].FI.SE == mid){
			if(uu - vv1[i].FI.SE > vv1[i].FI.SE - dd)dd = max(dd,vv1[i].FI.SE);
			else uu = min(uu,vv1[i].FI.SE);
		}
		else dd = max(dd,vv1[i].FI.SE);
	}
	nowA.PB(MP(L,MP(uu,dd)));
	uu = U,dd = D;
	for(ll i = 0;i < vv3.size();i++){
		nowB.PB(MP(vv3[i].FI.FI,MP(uu,dd)));
		if(vv3[i].FI.SE > mid)uu = min(uu,vv3[i].FI.SE);
		else if(vv3[i].FI.SE == mid){
			if(uu - vv3[i].FI.SE > vv3[i].FI.SE - dd)dd = max(dd,vv3[i].FI.SE);
			else uu = min(uu,vv3[i].FI.SE);
		}
		else dd = max(dd,vv3[i].FI.SE);
	}
	nowB.PB(MP(R,MP(uu,dd)));
	//cout << " IN SEICA " << nowA.size() << " " << nowB.size() << endl;
	ret = max(ret,nyan(nowA,nowB));
	REP(i,nowA.size())nowA[i].FI = R - nowA[i].FI;
	REP(i,nowB.size())nowB[i].FI = R - nowB[i].FI;
	ret = max(ret,nyan(nowB,nowA));
	
	return ret;
}

int main(){
	
	cin >> w >> h >> n;
	vector<P> v1;
	vector<P> v2;
	
	REP(i, n){
		ll a,b;cin >> a >> b;
		v1.PB(MP(MP(a,b),i));
		v2.PB(MP(MP(b,a),i));
	}
	
	sort(ALL(v1));
	sort(ALL(v2));
	
	cout << 2*max(seica(v1,v2,h,0,0,w),seica(v2,v1,w,0,0,h)) << endl;
	
	return 0;
}


Measured memory_bytes: 103984