#include <bits/stdc++.h>

using namespace std;

const int MX = 300009;

template <typename T> void read(T &x)
{
	x = 0; char c = getchar(); bool f = 0;
	while(!isdigit(c) && c!='-') c = getchar();
	if(c == '-') f = 1, c = getchar();
	while(isdigit(c)) x = x*10+c-'0', c = getchar();
	if(f) x = -x;
}

struct vec
{
	int x, y;
	int rx, ry;

	vec (const int &x0 = 0, const int &y0 = 0) : rx(x0), ry(y0) {}
};

struct QUR
{
	int l, r;
	int v;

	QUR (const int &l0 = 0, const int &r0 = 0, const int &v0 = 0) : l(l0), r(r0), v(v0) {}
};

struct SEGT
{
	#define ls (a<<1)
	#define rs (a<<1|1)
	#define mid ((l+r)>>1)

	int tre[MX*4];

	void upd(int a)
	{
		tre[a] = max(tre[ls], tre[rs]);
	}

	void mdf(int a, int l, int r, int p, int x)
	{
		if(l == r) tre[a] = max(tre[a], x);
		else if(p <= mid) mdf(ls, l, mid, p, x), upd(a);
		else mdf(rs, mid+1, r, p, x), upd(a);
	}

	int qur(int a, int l, int r, int ql, int qr)
	{
		if(ql<=l && r<=qr) return tre[a];
		else if(ql>r || qr<l) return -1e9;
		else return max(qur(ls, l, mid, ql, qr), qur(rs, mid+1, r, ql, qr));
	}

	void init()
	{
		memset(tre, 0x9f, sizeof(tre));
	}

	#undef ls
	#undef rs
	#undef mid
} T;

int w, h, n;
vec pot[MX];
int relx[MX], rely[MX];
int numx, numy;

void discrete()
{
	for(int i=1; i<=n; i++) relx[i] = pot[i].rx;
	sort(relx+1, relx+n+1);
	numx = unique(relx+1, relx+n+1) - relx - 1;
	for(int i=1; i<=n; i++) pot[i].x = lower_bound(relx+1, relx+numx+1, pot[i].rx) - relx;

	for(int i=1; i<=n; i++) rely[i] = pot[i].ry;
	sort(rely+1, rely+n+1);
	numy = unique(rely+1, rely+n+1) - rely - 1;
	for(int i=1; i<=n; i++) pot[i].y = lower_bound(rely+1, rely+numy+1, pot[i].ry) - rely;
}

void input()
{
	read(w), read(h), read(n);
	for(int i=1; i<=n; i++) read(pot[i].rx), read(pot[i].ry);
	pot[++n] = vec(0, 0);
	pot[++n] = vec(w, h);
	pot[++n] = vec(w, 0);
	pot[++n] = vec(0, h);
	discrete();
}

int scan(vector<QUR> qur, vector<QUR> mdf)
{
	int ret = 0;
	vector<QUR> in = mdf, out = mdf, qin = qur, qout = qur;
	sort(qin.begin(), qin.end(), [](const QUR &a, const QUR &b){return a.r < b.r;});
	sort(in.begin(), in.end(), [](const QUR &a, const QUR &b){return a.r < b.r;});
	sort(qout.begin(), qout.end(), [](const QUR &a, const QUR &b){return a.l < b.l;});
	sort(out.begin(), out.end(), [](const QUR &a, const QUR &b){return a.l < b.l;});
	T.init();
	auto itin = in.begin();
	for(auto q : qin)
	{
		while(itin!=in.end() && (itin->r)<=q.r)
		{
			T.mdf(1, 1, numy, (itin->l), rely[itin->r]-rely[itin->l]+(itin->v));
			itin++;
		}
		ret = max(ret, T.qur(1, 1, numy, q.l, q.r)+q.v);
	}
	T.init();
	auto itout = out.begin();
	for(auto q : qout)
	{
		while(itout!=out.end() && (itout->l)<=q.l)
		{
			T.mdf(1, 1, numy, (itout->r), rely[itout->r]+(itout->v));
			itout++;
		}
		ret = max(ret, T.qur(1, 1, numy, q.l, q.r)+q.v-rely[q.l]);
	}
	return ret;
}

int calc()
{
	int rkx[MX];
	for(int i=1; i<=n; i++) rkx[i] = i;
	sort(rkx+1, rkx+n+1, [=](int a, int b){return pot[a].x < pot[b].x;});
	set<int> st;
	vector<QUR> qur, mdf;
	st.insert(1), st.insert(numy);
	int mid = w/2;
	for(int i=1; i<=n; i++)
	{
		int p = rkx[i];
		if(pot[p].rx > mid)
		{
			if(pot[p].ry == 0) qur.push_back(QUR(1, *(++st.begin()), pot[p].rx-mid));
			else if(pot[p].ry == h) qur.push_back(QUR(*(++st.rbegin()), numy, pot[p].rx-mid));
			else qur.push_back(QUR(*(--st.upper_bound(pot[p].y)), *st.upper_bound(pot[p].y), pot[p].rx-mid));
			st.insert(pot[p].y);
		}
	}
	int lst = 1;
	for(auto i : st) qur.push_back(QUR(lst, i, w-mid)), lst = i;
	st.clear();
	st.insert(1), st.insert(numy);
	for(int i=n; i>=1; i--)
	{
		int p = rkx[i];
		if(pot[p].rx <= mid)
		{
			if(pot[p].ry == 0) mdf.push_back(QUR(1, *(++st.begin()), mid-pot[p].rx));
			else if(pot[p].ry == h) mdf.push_back(QUR(*(++st.rbegin()), numy, mid-pot[p].rx));
			else mdf.push_back(QUR(*(--st.upper_bound(pot[p].y)), *st.upper_bound(pot[p].y), mid-pot[p].rx));
			st.insert(pot[p].y);
		}
	}
	lst = 1;
	for(auto i : st) mdf.push_back(QUR(lst, i, mid)), lst = i;
	return max(scan(qur, mdf), scan(mdf, qur));
}

void work()
{
	int ans = 0;
	ans = max(ans, calc());
	swap(w, h);
	for(int i=1; i<=n+1; i++) swap(pot[i].x, pot[i].y), swap(pot[i].rx, pot[i].ry), swap(relx[i], rely[i]);
	swap(numx, numy);
	ans = max(ans, calc());
	printf("%d\n", ans*2);
}

int main()
{
	input();
	work();
	return 0;
}


Measured memory_bytes: 67292