#include <algorithm>
#include <cstring>
#include <cstdio>
struct point
{
	int x, y;
	inline bool operator <(const point& a) const
	{
		return x < a.x;
	}
} arr[300005], st1[300005], st2[300005];
int mx[1200005], lazy[1200005];
void modify(int u, int l, int r, int L, int R, int x)
{
	if (L <= l && r <= R)
	{
		mx[u] += x;
		lazy[u] += x;
		return;
	}
	int m = l + r >> 1;
	if (L <= m)
		modify(u << 1, l, m, L, R, x);
	if (m < R)
		modify(u << 1 | 1, m + 1, r, L, R, x);
	mx[u] = std::max(mx[u << 1], mx[u << 1 | 1]) + lazy[u];
}
int work(int w, int h, int n)
{
	memset(mx, -0x3f, sizeof(mx));
	memset(lazy, 0, sizeof(lazy));
	std::sort(arr, arr + n);
	int tp1 = 0, tp2 = 0, ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int& tp = arr[i].y <= h / 2 ? tp1 : tp2, nxt = i - 1;
		auto* st = arr[i].y <= h / 2 ? st1 : st2;
		while (tp && ((st[tp - 1].y < arr[i].y) ^ (arr[i].y > h / 2)))
		{
			modify(1, 0, n - 1, st[tp - 1].x, nxt, (st[tp - 1].y - arr[i].y) * (arr[i].y <= h / 2 ? 1 : -1));
			nxt = st[--tp].x - 1;
		}
		if (nxt != i - 1)
			st[tp++] = { nxt + 1, arr[i].y };
		st1[tp1++] = { i, 0 };
		st2[tp2++] = { i, h };
		modify(1, 0, n - 1, i, i, h - arr[i].x - mx[0]);
		ans = std::max(ans, mx[1] + arr[i + 1].x);
	}
	return ans;
}
int main()
{
	int w, h, n;
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 0; i < n; i++)
		scanf("%d%d", &arr[i].x, &arr[i].y);
	arr[n++] = { 0, 0 };
	arr[n++] = { w, h };
	int ans = work(w, h, n);
	for (int i = 0; i < n; i++)
		std::swap(arr[i].x, arr[i].y);
	ans = std::max(ans, work(h, w, n));
	printf("%d\n", ans << 1);
	return 0;
}