#include <bits/stdc++.h>

const int MAXN = 300010;
int W, H, n, ans;
struct _ { int x, y; } ps[MAXN];
int tag[MAXN << 3], tree[MAXN << 3], li[MAXN << 1], bak;
void mkadd(int u, int v) { tree[u] += v, tag[u] += v; }
void pushdown(int u) {
	if (int & t = tag[u]) {
		mkadd(u << 1, t);
		mkadd(u << 1 | 1, t);
		t = 0;
	}
}
void mdf(int u, int l, int r, int L, int R, int v) {
	if (L <= l && r <= R) return mkadd(u, v);
	int mid = l + r >> 1;
	pushdown(u);
	if (L <= mid) mdf(u << 1, l, mid, L, R, v);
	if (mid < R) mdf(u << 1 | 1, mid + 1, r, L, R, v);
	tree[u] = std::max(tree[u << 1], tree[u << 1 | 1]);
}
int qry(int u, int l, int r, int L, int R) {
	if (L <= l && r <= R) return tree[u];
	int mid = l + r >> 1, res = 0;
	pushdown(u);
	if (L <= mid) res = qry(u << 1, l, mid, L, R);
	if (mid < R) res = std::max(res, qry(u << 1 | 1, mid + 1, r, L, R));
	return res;
}
_ sl[MAXN], sr[MAXN]; int tl, tr;
void solve() {
	const int mx = W + 1 >> 1;
	memset(tree, 0, sizeof tree);
	memset(tag, 0, sizeof tag);
	std::sort(ps + 1, ps + 1 + n, [] (_ a, _ b) { return a.y < b.y; });
	for (int i = 1; i <= bak; ++i) mdf(1, 1, bak, i, i, W - li[i]);
	sl[tl = 1] = (_) {mx, 1}, sr[tr = 1] = (_) {mx + 1, 1};
	int cur = 1;
	for (int i = 1; i <= bak && li[i] <= H; ++i) {
		ans = std::max(ans, qry(1, 1, bak, 1, i) + li[i]);
		while (cur <= n && ps[cur].y == i) {
			bool b = li[ps[cur].x] <= mx;
			int & top = b ? tl : tr; _ * st = b ? sl : sr;
			mdf(1, 1, bak, st[top].y, bak, b ? -mx : mx - W);
			while (top > 1 && (b ? st[top].x <= ps[cur].x : st[top].x >= ps[cur].x)) {
				mdf(1, 1, bak, st[top - 1].y, st[top].y - 1, -std::abs(mx - li[st[top].x]));
				--top;
			}
			if (ps[cur].y > st[top].y) {
				st[++top] = ps[cur];
				mdf(1, 1, bak, st[top - 1].y, st[top].y - 1, std::abs(mx - li[st[top].x]));
			}
			mdf(1, 1, bak, st[top].y, bak, b ? mx : W - mx);
			++cur;
		}
	}
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> W >> H >> n; ans = std::max(H, W) + 1;
	for (int i = 1; i <= n; ++i) std::cin >> ps[i].x >> ps[i].y;
	for (int i = 1; i <= n; ++i) li[++bak] = ps[i].x;
	for (int i = 1; i <= n; ++i) li[++bak] = ps[i].y;
	li[++bak] = 0, li[++bak] = H, li[++bak] = W;
	std::sort(li + 1, li + 1 + bak);
	bak = std::unique(li + 1, li + 1 + bak) - li - 1;
	for (int i = 1; i <= n; ++i)
		ps[i].x = std::lower_bound(li + 1, li + 1 + bak, ps[i].x) - li;
	for (int i = 1; i <= n; ++i)
		ps[i].y = std::lower_bound(li + 1, li + 1 + bak, ps[i].y) - li;
	solve();
	std::swap(H, W);
	for (int i = 1; i <= n; ++i) std::swap(ps[i].x, ps[i].y);
	solve();
	std::cout << ans * 2 << std::endl;
	return 0;
}
