#include <iostream> 
#include <cstdio>
#include <cstring> 
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

#define For(i , a , b) for (int i = a , _b = b ; i <= _b ; ++i)
#define Ford(i , a  ,b) for (int i = a , _b = b : i >= _b ; --i)
#define Rep(i , n) for (int i = 0 , _n = n ; i < _n ; ++i)
#define sz(A) ((int)A.size())
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)

typedef pair<int , int> pt;
#define fi first
#define se second

const int maxn = 300000 + 123;
int n, W, H;
pt a[maxn];
int res = 0;

void ReadData() {
	cin >> W >> H >> n;
	For(i,1,n) {
		cin >> a[i].fi >> a[i].se;
	}
}

void maximize(int &a, const int b) {
	if (a < b) a = b;
}
void minimize(int &a, const int b) {
	if (a > b) a = b;
}

const int INF = 1e9;
int shore;
int prelog2[maxn];
const int lg = 19;
struct rmqMax{
	int n;
	int a[maxn];
	int r[maxn][lg + 3];

	void init(int _n, int a[]) {
		n = _n;
		For(i,1,n) r[i][0] = a[i];
		For(j,0,lg - 1) For(i,1,n) {
			if (i + (1 << (j + 1)) - 1 <= n) {
				r[i][j + 1] = max(r[i][j], r[i + (1 << j)][j]);
			}
		}
	}
	int get(int l, int h) {
		if (l > h) return 0;
		int z = prelog2[h - l + 1];
		return max(r[l][z], r[h - (1 << z) + 1][z]);
	}
} rmax;
struct rmqMin{
	int n;
	int a[maxn];
	int r[maxn][lg + 3];

	void init(int _n, int a[]) {
		n = _n;
		For(i,1,n) r[i][0] = a[i];
		For(j,0,lg - 1) For(i,1,n) {
			if (i + (1 << (j + 1)) - 1 <= n) {
				r[i][j + 1] = min(r[i][j], r[i + (1 << j)][j]);
			}
		}
	}
	int get(int l, int h) {

		if (l > h) return H;
		int z = prelog2[h - l + 1];
		return min(r[l][z], r[h - (1 << z) + 1][z]);
	}
} rmin;



int sta[maxn], top;
int baoNgoc(int l, int r) {
	if (l == r) return 0;
	if (l > r) return 0;
	return  a[r].fi - a[l].fi + rmin.get(l + 1,r - 1) - rmax.get(l + 1,r - 1);
}
int firstBetter(int i, int j) {
	int l = j + 1, r = n, res = n + 1;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (baoNgoc(i, mid) >= baoNgoc(j, mid)) {
			res = mid;
			r = mid - 1;
		} else l = mid + 1;
	} 
	return res;
}

int tmp[maxn];
int solve(int _shore) { /// separated by Y
	int res = 0;
	shore = _shore;
	sort(a + 1, a + 1 + n);

	top = 0;
	For(i,1,n) {
		if (a[i].se <= shore) tmp[i] = a[i].se; else tmp[i] = 0; 
	}
	rmax.init(n,tmp);
	For(i,1,n) {
		if (a[i].se > shore) tmp[i] = a[i].se; else tmp[i] = H;
	}
	rmin.init(n,tmp);

	maximize(res, a[1].fi + H);
	maximize(res, W - a[n].fi + H);
	maximize(res, W + rmin.get(1,n) - rmax.get(1,n));

	sta[++top] = 1;
	maximize(res, W - a[1].fi + rmin.get(1 + 1,n) - rmax.get(1 + 1,n));
	For(i,2,n) {
		maximize(res, a[i].fi + rmin.get(1, i - 1) - rmax.get(1, i - 1));
		if (i < n) {
			maximize(res, W - a[i].fi + rmin.get(i + 1,n) - rmax.get(i + 1,n));
		}
		while (top >= 2 && firstBetter(sta[top - 1], sta[top]) <= i) --top;
		maximize(res, baoNgoc(sta[top], i));
		while (top >= 2 && firstBetter(sta[top - 1], sta[top]) <=
			firstBetter(sta[top], i)) --top;
		sta[++top] = i;
	}
	return res;
}

void Process() {
	res = max(res,solve(H / 2 ));
//	res = max(res, solve(H / 2 - 1));
	swap(W, H);
	For(i,1,n) swap(a[i].fi, a[i].se);
	res = max(res, solve(H / 2));
//res = max(res, solve(H / 2 - 1));

	cout << 2LL * res << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	For(i,1,300000) prelog2[i] = (int) log2(i);
	//freopen("input.inp" , "r" , stdin);
	ReadData();
	Process();

	return 0;

}			

Measured memory_bytes: 59776