#include<bits/stdc++.h>
#define fo(i, x, y) for(int i = x, _b = y; i <= _b; i ++)
#define ff(i, x, y) for(int i = x, _b = y; i <  _b; i ++)
#define fd(i, x, y) for(int i = x, _b = y; i >= _b; i --)
#define ll long long
#define pp printf
#define hh pp("\n")
using namespace std;

const int N = 3e5 + 5;

int w, h, n;

struct P {
	int x, y;
} a[N];

int ans;

int d[N], d0;

map<int, int> rd;

void ls() {
	d0 = 0; d[++ d0] = 0; d[++ d0] = w;
	fo(i, 1, n) d[++ d0] = a[i].x;
	sort(d + 1, d + d0 + 1);
	d0 = unique(d + 1, d + d0 + 1) - (d + 1);
	rd.clear(); fo(i, 1, d0) rd[d[i]] = i;
}

P b[N], c[N]; int b0, c0;

int op;

int cmp1(P a, P b) {
	if(a.x == b.x) {
		if(a.y == b.y) return 0;
		return (a.y < b.y) ^ op;
	}
	return a.x < b.x;
}

void gg(P *a, int &a0) {
	sort(a + 1, a + a0 + 1, cmp1);
	int A = a0; a0 = 0;
	fo(i, 1, A) if(i == 1 || a[i].x != a[a0].x)
		a[++ a0] = a[i];
}

int t[N * 4], lz[N * 4], pl, pr, px;
#define i0 i + i
#define i1 i + i + 1
void jia(int i, int x) { t[i] += x, lz[i] += x;}
void down(int i) { if(lz[i]) jia(i0, lz[i]), jia(i1, lz[i]), lz[i] = 0; }
void add(int i, int x, int y) {
	if(y < pl || x > pr) return;
	if(x >= pl && y <= pr) { jia(i, px); return;}
	int m = x + y >> 1; down(i);
	add(i0, x, m); add(i1, m + 1, y);
	t[i] = max(t[i0], t[i1]);
}
void pla(int x, int y, int z) {
	pl = x, pr = y, px = z;
	add(1, 1, d0);
}

int z1[N], z2[N];

void ad1(int f) {
	P u = b[z1[z1[0] - 1]], v = b[z1[z1[0]]];
	pla(rd[u.x], rd[v.x] - 1, f * (h - v.y));
}

void ad2(int f) {
	P u = c[z2[z2[0] - 1]], v = c[z2[z2[0]]];
	pla(rd[u.x], rd[v.x] - 1, f * v.y);
}

void work() {
	ls();
	b0 = c0 = 0;
	fo(i, 1, n)	if(a[i].x) {
		if(a[i].y >= h / 2) b[++ b0] = a[i];
		if(a[i].y <= h / 2) c[++ c0] = a[i];
	}
	op = 0; gg(b, b0);
	op = 1; gg(c, c0);
	
	fo(i, 1, d0 * 4) lz[i] = 0, t[i] = 0;
	
	b[0] = c[0] = (P) {0, h / 2};
	z1[0] = z2[0] = 1;
	z1[1] = z2[1] = 0;
	
	int l1 = 1, l2 = 1;
	fo(i, 1, d0) {
		while(l1 <= b0 && b[l1].x < d[i]) {
			while(b[l1].y < b[z1[z1[0]]].y)
				ad1(1), z1[0] --;
			z1[++ z1[0]] = l1; ad1(-1);
			l1 ++;
		}
		while(l2 <= c0 && c[l2].x < d[i]) {
			while(c[l2].y > c[z2[z2[0]]].y)
				ad2(1), z2[0] --;
			z2[++ z2[0]] = l2; ad2(-1);
			l2 ++;
		}
		ans = max(ans, t[1] + d[i]);
		
		pl = pr = i; px = h - d[i];
		add(1, 1, d0);
	}
	
}

int main() {
	scanf("%d %d %d", &w, &h, &n);
	fo(i, 1, n) scanf("%d %d", &a[i].x, &a[i].y), a[i].x *= 2, a[i].y *= 2;
	w *= 2, h *= 2;
	ans = max(w, h);
	work();
	swap(w, h); fo(i, 1, n) swap(a[i].x, a[i].y);
	work();
	pp("%d\n", ans);
}