#include <bits/stdc++.h>
#define maxn 600086

using namespace std;

struct Node{
	int sum, pl;
}t[maxn << 2];

#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)

inline void up(int x){
	t[x].sum = max(t[ls(x)].sum, t[rs(x)].sum);
}

inline void add(int x, int y){
	t[x].sum += y, t[x].pl += y;
}

inline void down(int x){
	if(t[x].pl){
		add(ls(x), t[x].pl);
		add(rs(x), t[x].pl);
		t[x].pl = 0;
	}
}

void modify(int x, int l, int r, int ll, int rr, int d){
	if(ll <= l && r <= rr){
		add(x, d);
		return;
	}
	down(x);
	int mid = l + r >> 1;
	if(mid >= ll) modify(ls(x), l, mid, ll, rr, d);
	if(mid < rr) modify(rs(x), mid + 1, r, ll, rr, d);
	up(x);
}

int query(int x, int l, int r, int ll, int rr){
	if(ll <= l && r <= rr) return t[x].sum;
	down(x);
	int mid = l + r >> 1, sum = 0;
	if(mid >= ll) sum = max(sum, query(ls(x), l, mid, ll, rr));
	if(mid < rr) sum = max(sum, query(rs(x), mid + 1, r, ll, rr));
	return sum;
}

int n, m, k;
int x[maxn], y[maxn];
int ans;
vector<int> v;
int a[2][maxn];
int sk[2][maxn], top[2];

void cal(){
	v.clear();
	memset(t, 0, sizeof(t));
	for(int i = 1;i <= k;i++) v.push_back(x[i]);
	v.push_back(0), v.push_back(n);
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	int n0 = v.size();
	for(int i = 1;i <= n0;i++) a[0][i] = 0, a[1][i] = m;
	for(int i = 1;i <= k;i++){
		int j = lower_bound(v.begin(), v.end(), x[i]) - v.begin() + 1;
		if(y[i] < m / 2) a[0][j] = max(a[0][j], y[i]);
		else a[1][j] = min(a[1][j], y[i]);
	}
	top[0] = top[1] = 0;
	for(int i = 1;i <= n0;i++){
		if(i > 1){
			ans = max(ans, 2 * (query(1, 1, n0, 1, i - 1) + v[i - 1])); 
			ans = max(ans, 2 * (v[i - 1] - v[i - 2] + m));
		}
		while(top[0] && a[0][sk[0][top[0]]] <= a[0][i]){
			modify(1, 1, n0, sk[0][top[0] - 1] + 1, sk[0][top[0]], -(m / 2 - a[0][sk[0][top[0]]]));
			--top[0];
		}
		modify(1, 1, n0, sk[0][top[0]] + 1, i, m / 2 - a[0][i]);
		sk[0][++top[0]] = i;
		
		while(top[1] && a[1][sk[1][top[1]]] >= a[1][i]){
			modify(1, 1, n0, sk[1][top[1] - 1] + 1, sk[1][top[1]], -(a[1][sk[1][top[1]]] - m / 2));
			--top[1];
		}
		modify(1, 1, n0, sk[1][top[1]] + 1, i, a[1][i] - m / 2);
		sk[1][++top[1]] = i;
		
		modify(1, 1, n0, i, i, i - 2 >= 0 ? -v[i - 2] : 0);
		//printf("%d %d--\n", i, i - 2 >= 0 ? -v[i - 2] : 0);
		
		
	}
}

int main(){
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1;i <= k;i++) scanf("%d%d", &x[i], &y[i]);
	cal();
	for(int i = 1;i <= k;i++) swap(x[i], y[i]);
	swap(n, m);
	cal();
	printf("%d", ans);
}