#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

struct segtree{
	using D = int;
	D inf = 1e9;

	int N;
	vector<D> val;

	segtree(){}
	segtree(int n){
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,-inf);
	}
	segtree(const vector<D>& ds){
		int n = ds.size();
		N=1;
		while(N<n) N*=2;
		val.assign(N*2,-inf);
		rep(i,n) val[i+N] = ds[i];
		for(int i=N-1;i>0;i--) val[i] = max(val[i*2],val[i*2+1]);
	}
	void assign(int k,D d){
		k+=N;
		val[k]=d;
		k/=2;
		while(k){
			val[k] = max(val[k*2],val[k*2+1]);
			k/=2;
		}
	}
	D getmax(int a,int b){
		D res = -inf;
		a+=N,b+=N;
		while(a<b){
			if(a&1) chmax(res,val[a++]);
			if(b&1) chmax(res,val[--b]);
			a/=2,b/=2;
		}
		return res;
	}
};
int solve(V<int> X,V<int> Y,int W,int H){
	int N = X.size();
	V<int> ys = Y; ys.pb(0);ys.pb(H);
	mkuni(ys);
	int K = si(ys)-1;
	map<int,int> y2x;
	rep(i,N) y2x[Y[i]] = X[i];
	struct Waf{
		int d,u,x;
		Waf(int d_,int u_,int x_):d(d_),u(u_),x(x_){}
	};
	int res = 0;
	function<void(int,int)> func = [&](int lb,int ub){
		if(lb >= ub) return;
		int yran = (lb+ub)/2;
		func(lb,yran);
		func(yran+1,ub);
		int ty = (ys[yran]+ys[yran+1])/2;
		using P = pair<int,int>;
		V<P> L_xys,R_xys;
		for(int i=lb+1;i<=ub-1;i++){
			int y = ys[i], x = y2x[y];
			if(x <= W/2){
				L_xys.pb(W/2-x,y);
			}else{
				R_xys.pb(x-W/2,y);
			}
		}
		sort(all(L_xys)); sort(all(R_xys));
		V<Waf> L,R;
		rep(_,2){
			int d = ys[lb], u = ys[ub];
			for(P xy: (_ == 0 ? L_xys : R_xys)){
				int x,y; tie(x,y) = xy;
				(_ == 0 ? L : R).pb(d,u,x);
				if(ty < y){
					chmin(u,y);
				}else{
					chmax(d,y);
				}
			}
			(_ == 0 ? L : R).pb(d,u,W/2);
		}
		auto f = [&](Waf a, Waf b){
			return (min(a.u,b.u)-max(a.d,b.d)) + a.x+b.x;
		};
		rep(dir,2){
			// for(Waf a: L){
			// 	for(Waf b: R){
			// 		int tmp = (min(a.u,b.u)-max(a.d,b.d)) + a.x+b.x;
			// 		chmax(res,tmp);
			// 	}
			// }
			{	//1. l \in r
				int j = -1;
				rep(i,si(L)){
					while(j+1 < si(R) && R[j+1].d <= L[i].d && L[i].u <= R[j+1].u) j++;
					assert(j >= 0);	//[0,H]
					chmax(res,f(L[i],R[j]));
				}
			}
			{	//2. l.d <= r.d && l.u <= r.u
				segtree seg(si(R));
				rep(i,si(R)) seg.assign(i,R[i].x-R[i].d);
				rep(i,si(L)){
					int j0,j1;
					{
						int a = -1, b = si(R);
						while(b-a>1){
							int m = (a+b)/2;
							if(L[i].d <= R[m].d) b = m;
							else a = m;
						}
						j0 = b;
					}
					{
						int a = -1, b = si(R);
						while(b-a>1){
							int m = (a+b)/2;
							if(L[i].u <= R[m].u) a = m;
							else b = m;
						}
						j1 = a;
					}
					if(j0 <= j1){
						int tmp = L[i].u + L[i].x + seg.getmax(j0,j1+1);
						chmax(res,tmp);
					}
				}
			}
			swap(L,R);
		}
	};
	func(0,K);
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int W,H; cin >> W >> H; W *= 2, H *= 2;
	int N; cin >> N;
	V<int> X(N),Y(N);
	rep(i,N){
		cin >> X[i] >> Y[i];
		X[i] *= 2, Y[i] *= 2;
	}
	cout << max(solve(X,Y,W,H),solve(Y,X,H,W)) << endl;
}


Measured memory_bytes: 36476