#include "bits/stdc++.h"
using namespace std;


int w;
int h;
int n;

vector < pair<int, int> > v;

vector<pair<int,int> > up;
vector<pair<int,int> > dw;

#define MAX 300002

int seg[MAX * 4];
int lazy[MAX * 4];

void update(int b) {
	seg[b] += lazy[b];
	if (b * 2 + 2 < MAX * 4) {
		lazy[b * 2 + 1] += lazy[b];
		lazy[b * 2 + 2] += lazy[b];
	}
	lazy[b] = 0;
}

inline void add(int b, int l, int r, int ll, int rr,int x) {
	if (l >= r) {
		return;
	}
	update(b);
	if (r <= ll || rr <= l) {
		return;
	}
	if (ll <= l&&r <= rr) {
		lazy[b] = x;
		update(b);
		return;
	}
	add(b * 2 + 1, l, (l + r) >> 1, ll, rr, x);
	add(b * 2 + 2, (l + r) >> 1, r, ll, rr, x);
	seg[b] = max(seg[b * 2 + 1], seg[b * 2 + 2]);
}
inline int query(int b, int l, int r, int ll, int rr) {
	update(b);
	if (r <= ll || rr <= l) {
		return -1;
	}
	if (ll <= l&&r <= rr) {
		return seg[b];
	}
	int ans1=query(b * 2 + 1, l, (l + r) >> 1, ll, rr);
	int ans2=query(b * 2 + 2, (l + r) >> 1, r, ll, rr);
	return max(ans1, ans2);
}
map<int, int> mp;
int solve() {
	memset(seg, 0, sizeof(seg));
	memset(lazy, 0, sizeof(lazy));
	int mid = h / 2;
	int sz = v.size();
	mp.clear();
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size(); i++) {
		mp[v[i].first] = 0;
	} {
		int cn = 0;
		for (auto it = mp.begin(); it != mp.end(); it++) {
			(*it).second = cn;
			cn++;
		}
	}
	up.clear();
	dw.clear();
	up.push_back(make_pair(0,0) );
	dw.push_back(make_pair(0,0) );
	int base = mp.size();
	//mp.size()
	auto EAT = mp.begin();
	for (int i = 0; i < mp.size(); i++) {
		add(0, 0, mp.size(), i, i + 1, w - (*EAT).first);
		EAT++;
	}
	int ans = INT_MIN;
	int pr = -1;
	for (int i = 0; i < v.size(); i++) {
		int H = v[i].second - mid;
		int pad = w - v[i].first;
		int ww = mp[v[i].first];
		if (pr != ww) {
			pr = ww;
			add(0, 0, mp.size(), up.back().second, ww + 1, mid);
			add(0, 0, mp.size(), dw.back().second, ww + 1, mid);
			ans = max(ans, query(0, 0, mp.size(), 0, ww + 1) - (w - v[i].first));
			add(0, 0, mp.size(), up.back().second, ww + 1, -mid);
			add(0, 0, mp.size(), dw.back().second, ww + 1, -mid);
		}
		if (H >= 0) {
			while (up.size()>1 && up[up.size()-1].first > H) {
				int lef = up[up.size() - 2].second;
				int rig = up[up.size() - 1].second;
				int val = up.back().first;
				add(0, 0, mp.size(), lef, rig, -val);
				up.pop_back();
			}
			add(0, 0, mp.size(), up.back().second, ww, H);
			up.push_back(make_pair(H, ww));
		}
		if (H < 0) {
			H = abs(H);
			while (dw.size()>1 && dw[dw.size() - 1].first > H) {
				int lef = dw[dw.size() - 2].second;
				int rig = dw[dw.size() - 1].second;
				int val = dw.back().first;
				add(0, 0, mp.size(), lef, rig, -val);
				dw.pop_back();
			}
			add(0, 0, mp.size(), dw.back().second, ww, H);
			dw.push_back(make_pair(H, ww));
		}
	}
	return ans;
}

int main() {
	cin >> w >> h >> n;
	w *= 2;
	h *= 2;
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		a *= 2;
		b *= 2;
		v.push_back(make_pair(a, b));
	}
	v.push_back({ 0, 0 });
	v.push_back({ w, h });
	v.push_back({ 0, h });
	v.push_back({ w, h });
	sort(v.begin(), v.end());
	int ans1 = solve();
	swap(w, h);
	for (int i = 0; i < v.size(); i++) {
		swap(v[i].first, v[i].second);
	}
	int ans2 = solve();
	ans1 = max(ans1, ans2);
	cout << ans1 << endl;
	return 0;
}

Measured memory_bytes: 30828