#include <bits/stdc++.h>
using namespace std;
#define int long long int
const int SIZE = 1 << 18; char STR[SIZE], *BEG = STR, *END = STR;
inline char get() { if(BEG == END) END = (BEG = STR) + fread(STR, 1, SIZE, stdin); return (BEG == END? EOF: *(BEG++)); }
inline int read() {
	int x = 0, op = 1; char ch = 0;
	while(not isdigit(ch = get())) if(ch == '-') op = -op;
	do x = (x << 3) + (x << 1) + (ch - '0'); while(isdigit(ch = get()));
	return op * x;
}
const int inf = 10000000000000LL;
int w = 0, h = 0, n = 0; pair<int, int> pos[300500];
int xds[300500 << 2], laz[300500 << 2];
inline void flsh(int t, int l, int r) {
	if(laz[t]) {
		if(l < r) laz[t << 1] += laz[t], laz[t << 1 | 1] += laz[t];
		xds[t] += laz[t], laz[t] = 0;
	}
}
void add(int u, int v, int s, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return;
	if(u <= l and r <= v) {
		laz[t] += s;
		flsh(t, l, r);
	} else {
		flsh(t << 1, l, (l + r) >> 1), flsh(t << 1 | 1, ((l + r) >> 1) + 1, r);
		if(u <= (l + r) >> 1) add(u, v, s, t << 1, l, (l + r) >> 1);
		if(v > (l + r) >> 1) add(u, v, s, t << 1 | 1, ((l + r) >> 1) + 1, r);
		xds[t] = max(xds[t << 1], xds[t << 1 | 1]);
	}
}
int sol(int u, int v, int t, int l, int r) {
	flsh(t, l, r);
	if(u > v) return -inf;
	if(u <= l and r <= v) return xds[t];
	else {
		int p = -inf;
		if(u <= (l + r) >> 1) p = max(p, sol(u, v, t << 1, l, (l + r) >> 1));
		if(v > (l + r) >> 1) p = max(p, sol(u, v, t << 1 | 1, ((l + r) >> 1) + 1, r));
		return p;
	}
}
int solve() {
	sort(pos + 1, pos + n + 1);
	stack<pair<int, int> > up, down;
	memset(laz, 0, sizeof laz), memset(xds, 0, sizeof xds);
	int rez = 0;
	for(int i = 1; i <= n; i++) {
		int las = i - 1;
		if(pos[i].second > h / 2) {
			while(not up.empty() and up.top().second >= pos[i].second) {
				if(up.top().second != pos[i].second) add(up.top().first, las, pos[i].second - up.top().second, 1, 1, n);
				las = up.top().first - 1, up.pop();
			}
			if(las < i - 1) up.push(make_pair(las + 1, pos[i].second));
		} else {
			while(not down.empty() and down.top().second <= pos[i].second) {
				if(down.top().second != pos[i].second) add(down.top().first, las, down.top().second - pos[i].second, 1, 1, n);
				las = down.top().first - 1, down.pop();
			}
			if(las < i - 1) down.push(make_pair(las + 1, pos[i].second));
		}
		up.push(make_pair(i, h)), down.push(make_pair(i, 0));
		add(i, i, h - pos[i].first, 1, 1, n); // 总高度-左边界 
		rez = max(rez, pos[i + 1].first + sol(1, n, 1, 1, n)); // 最大值+右边界 
	}
	return rez << 1;
}
signed main() {

	w = read(), h = read(), n = read();
	for(int i = 1; i <= n; i++) pos[i].first = read(), pos[i].second = read();
	n++, pos[n] = make_pair(w, h), n++, pos[n] = make_pair(0, 0);
	int ans = 0;
	ans = max(ans, solve());
	swap(w, h); for(int i = 1; i <= n; i++) swap(pos[i].first, pos[i].second);
	ans = max(ans, solve());
	cout << ans << endl;
	return 0;
}