#pragma GCC optimize "-O3"
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int INF = 1e9;
const int MAXN = 310000;

pair<int, int> a[MAXN];
vector<int> vv;
int nl[MAXN];
int nr[MAXN];
set<int> ss;
int rmq1[MAXN * 4];
int rmq2[MAXN * 4];
int w, h;
int n;
int ans = 0;
vector<pair<int, int> > op[MAXN];
vector<int> cl[MAXN];

int start = 0;
int tm = 0;

int fnd(int x) {
	return lower_bound(vv.begin(), vv.end(), x) - vv.begin();
}

void buildrmq(int, int, int tr) {
	int n = tr;
	for (int i = 0; i < 2 * n; ++i)
		rmq1[i] = -INF, rmq2[i] = INF;
}

void upd2(int , int , int tr, int x, int y) {
	int n = tr;
	x += n - 1;
	while (x >= 0) {
		rmq2[x] = min(rmq2[x], y);
		x = (x - 1) >> 1;
	}
}

void upd(int , int , int tr, int x, int y) {
	int n = tr;
	x += n - 1;
	rmq1[x] = y;
	while (x > 0) {
		x = (x - 1) >> 1;
		rmq1[x] = max(rmq1[x * 2 + 1], rmq1[x * 2 + 2]);
	}
}

int gt(int , int , int tr, int l, int r) {
	int n = tr;
	l += n - 1;
	r += n - 1;
	int ans = -INF;
	for (; l < r; l = (l - 1) >> 1, r = (r - 1) >> 1) {
		if (!(l & 1))
			ans = max(ans, rmq1[l++]);
		if (!(r & 1))
			ans = max(ans, rmq1[--r]);
	}
	return ans;
}

int gt2(int , int , int tr, int l, int r) {
	int n = tr;
	l += n - 1;
	r += n - 1;
	int ans = INF;
	for (; l < r; l = (l - 1) >> 1, r = (r - 1) >> 1) {
		if (!(l & 1))
			ans = min(ans, rmq2[l++]);
		if (!(r & 1))
			ans = min(ans, rmq2[--r]);
	}
	return ans;
}

int gt(int l, int r) {
	l = fnd(l);
	r = fnd(r + 1);
	if (l >= r)
		return -INF;
	return gt(0, 0, vv.size(), l, r);
}

int gt2(int l, int r) {
	l = fnd(l);
	r = fnd(r + 1);
	if (l >= r)
		return INF;
	int x = gt2(0, 0, vv.size(), l, r);
	return x;
}

int gl, gr;
int bdl(int x) {
	return (gr - a[x].first + nr[x] - nl[x]) <= ans;
}
int bdr(int x) {
	return (a[x].first - gl + nr[x] - nl[x]) <= ans;
}

void run(int l, int r) {
	if (l + 1 == r)
		return;
	if (a[r - 1].first - a[l].first + 2 * h <= ans)
		return;
	int m = (l + r) / 2;
	run(l, m);
	run(m, r);
	ss.clear();
	gl = a[l].first;
	gr = a[r - 1].first;
	for (int i = m - 1; i >= l; --i) {
		nr[i] = h;
		nl[i] = 0;
		auto it = ss.insert(a[i].second).first;
		if (next(it) != ss.end())
			nr[i] = *next(it);
		if (it != ss.begin())
			nl[i] = *prev(it);
	}
	ss.clear();
	for (int i = m; i < r; ++i) {
		nr[i] = h;
		nl[i] = 0;
		auto it = ss.insert(a[i].second).first;
		if (next(it) != ss.end())
			nr[i] = *next(it);
		if (it != ss.begin())
			nl[i] = *prev(it);
	}
	start = clock();
	//build begin
	vv.clear();
	for (int i = l; i < r; ++i)
		vv.push_back(a[i].second);
	sort(vv.begin(), vv.end());
	buildrmq(0, 0, vv.size());
	for (int i = m; i < r; ++i)
		upd2(0, 0, vv.size(), fnd(a[i].second), i);
	//build end
	for (int i = m - 1; i >= l; --i) {
		if (bdl(i))
			continue;
		int x = gt2(nl[i], nr[i]);
		if (x != INF)
			ans = max(ans, a[x].first - a[i].first + nr[i] - nl[i]);
	}
	for (int i = m - 1; i >= l; --i) {
		if (bdl(i))
			continue;
		int x = gt2(nl[i], a[i].second);
		if (x != INF)
			ans = max(ans, a[x].first - a[i].first + min(nr[i], nr[x]) - nl[i]);
	}
	for (int i = l; i < r; ++i)
		op[i].clear(), cl[i].clear();
	for (int i = m - 1; i >= l; --i) {
		if (bdl(i))
			continue;
		int x = fnd(a[i].second);
		int rb = gt2(a[i].second, nr[i]);
		if (rb == INF)
			rb = r;
		int lb = gt2(nl[i], a[i].second);
		if (lb == INF)
			continue;
		++lb;
		if (lb < rb) {
			op[lb].push_back(make_pair(x, nr[i] - a[i].first));
			if (rb != r)
				cl[rb].push_back(x);
		}
	}
	for (int i = m; i < r; ++i) {
		for (auto j: op[i])
			upd(0, 0, vv.size(), j.first, j.second);
		for (int j: cl[i])
			upd(0, 0, vv.size(), j, -INF);
		ans = max(ans, a[i].first - nl[i] + gt(a[i].second, nr[i]));
	}
	//build begin
	buildrmq(0, 0, vv.size());
	for (int i = l; i < m; ++i)
		upd2(0, 0, vv.size(), fnd(a[i].second), -i);
	//build end
	for (int i = m; i < r; ++i) {
		if (bdr(i))
			continue;
		int x = -gt2(nl[i], nr[i]);
		if (x != -INF)
			ans = max(ans, -a[x].first + a[i].first + nr[i] - nl[i]);
	}
	for (int i = m; i < r; ++i) {
		if (bdr(i))
			continue;
		int x = -gt2(nl[i], a[i].second);
		if (x != -INF)
			ans = max(ans, -a[x].first + a[i].first + min(nr[i], nr[x]) - nl[i]);
	}
	for (int i = m; i < r; ++i) {
		if (bdr(i))
			continue;
		int x = fnd(a[i].second);
		int rb = -gt2(a[i].second, nr[i]);
		if (rb == -INF)
			rb = l - 1;
		int lb = -gt2(nl[i], a[i].second);
		if (lb == -INF)
			continue;
		--lb;
		if (lb > rb) {
			op[lb].push_back(make_pair(x, nr[i] + a[i].first));
			if (rb != l - 1)
				cl[rb].push_back(x);
		}
	}
	for (int i = m - 1; i >= l; --i) {
		for (auto j: op[i])
			upd(0, 0, vv.size(), j.first, j.second);
		for (int j: cl[i])
			upd(0, 0, vv.size(), j, -INF);
		ans = max(ans, -a[i].first - nl[i] + gt(a[i].second, nr[i]));
	}
	tm += clock() - start;
}

void solve() {
	sort(a, a + n);
	ss.clear();
	for (int i = 0; i < n; ++i) {
		auto it = ss.lower_bound(a[i].second);
		int lb = 0;
		int rb = h;
		if (it != ss.end())
			rb = *it;
		if (it != ss.begin()) {
			--it;
			lb = *it;
		}
		ans = max(ans, rb - lb + a[i].first);
		ss.insert(a[i].second);
	}
}

void solve2() {
	sort(a, a + n);
	run(0, n);
}


bool cmp(pair<int, int> a, pair<int, int> b) {
	return make_pair(a.second, a.first) < make_pair(b.second, b.first);
}

int main() {
	scanf("%d%d%d", &w, &h, &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &a[i].first, &a[i].second);
	sort(a, a + n, cmp);
	ans = max(ans, a[0].second + w);
	ans = max(ans, h - a[n - 1].second + w);
	for (int i = 0; i < n - 1; ++i)
		ans = max(ans, a[i + 1].second - a[i].second + w);
	solve();
	for (int i = 0; i < n; ++i)
		a[i].first = w - a[i].first;
	solve();
	for (int i = 0; i < n; ++i)
		swap(a[i].first, a[i].second);
	swap(h, w);
	ans = max(ans, a[0].second + w);
	ans = max(ans, h - a[n - 1].second + w);
	for (int i = 0; i < n - 1; ++i)
		ans = max(ans, a[i + 1].second - a[i].second + w);
	solve();
	for (int i = 0; i < n; ++i)
		a[i].first = w - a[i].first;
	solve();
	cerr << "ok\n";
	solve2();
	cout << ans * 2 << "\n";
	cerr << (ld)tm / CLOCKS_PER_SEC << "\n";
	return 0;
}




Measured memory_bytes: 39536