//*
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <functional>
#define MOD 1000000007
#define MAX 0x3f3f3f3f
#define MAX2 0x3f3f3f3f3f3f3f3fll
#define ERR 1e-10
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#pragma warning(disable:4996)
using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

ll w, h;
int n;
pll a[400000];

ll ans;

ll xc;

vector<pll> le, re;
vector<pair<ll, pll>> lg, rg;
vector<int> v;

ll intlen(pll x, pll y)
{
	return min(x.second, y.second)-max(x.first, y.first);
}

void dodo(int st, int en, ll xdown, ll xup)
{
	if(st > en) return;
	int mid=(st+en)/2;
	ll yc;
	if(st < en) yc=(a[mid].second+a[mid+1].second)/2;
	else
	{
		if(a[mid].second+1 >= xdown && a[mid].second+1 <= xup) yc=a[mid].second+1;
		else yc=a[mid].second-1;
	}
	int i, j, k;
	le.clear(), re.clear(), lg.clear(), rg.clear();
	v.clear();
	for(i=st;i<=en;i++)
	{
		if(a[i].first <= xc) le.push_back(a[i]);
		else re.push_back(a[i]);
	}
	sort(all(le)), sort(all(re));
	ll up=xup, down=xdown;
	for(i=le.size()-1;i>=0;i--)
	{
		pll u=le[i];
		lg.emplace_back(u.first, mp(down, up));
		if(u.second > yc) up=min(up, u.second);
		else down=max(down, u.second);
	}
	lg.emplace_back(0, mp(down, up));
	reverse(all(lg));
	up=xup, down=xdown;
	for(i=0;i<re.size();i++)
	{
		pll u=re[i];
		rg.emplace_back(u.first, mp(down, up));
		if(u.second > yc) up=min(up, u.second);
		else down=max(down, u.second);
	}
	rg.emplace_back(w, mp(down, up));
	int ix1=rg.size(), ix2=rg.size();
	int vix=0;
	ll tmax=0;
	for(i=0;i<lg.size();i++)
	{
		auto u=lg[i];
		while(ix1 > 0 && !(rg[ix1-1].second.first <= u.second.first && u.second.second <= rg[ix1-1].second.second))
		{
			while(v.size() > vix && intlen(rg[v.back()].second, u.second)+rg[v.back()].first-u.first <= intlen(rg[ix1-1].second, u.second)+rg[ix1-1].first-u.first)
			{
				v.pop_back();
			}
			v.push_back(ix1-1);
			ix1--;
		}
		while(ix2 > 0 && u.second.first <= rg[ix2-1].second.first && rg[ix2-1].second.second <= u.second.second && u.second != rg[ix2-1].second)
		{
			if(v.size() > vix && v[vix] == ix2-1) vix++;
			tmax=max(tmax, rg[ix2-1].second.second-rg[ix2-1].second.first+rg[ix2-1].first);
			ix2--;
		}
		if(ix1 != 0) ans=max(ans, u.second.second-u.second.first+rg[ix1-1].first-u.first);
		if(ix1 <= ix2-1 && v.size() > vix) ans=max(ans, intlen(rg[v[vix]].second, u.second)+rg[v[vix]].first-u.first);
		if(ix2 <= rg.size()-1) ans=max(ans, tmax-u.first);
	}
	if(st == en) return;
	dodo(st, mid, xdown, yc);
	dodo(mid+1, en, yc, xup);
}

int main()
{
	int i, j, k, l;
	cin>>w>>h>>n;
	for(i=0;i<n;i++) scanf("%lld%lld", &a[i].first, &a[i].second), a[i].first*=2, a[i].second*=2;
	w*=2, h*=2;
	for(k=0;k<2;k++)
	{
		xc=w/2;
		if(xc%2 == 0) xc++;
		sort(a, a+n, [](pll x, pll y){return x.second < y.second;});
		ll dmax=0;
		for(i=0;i<n-1;i++) dmax=max(dmax, a[i+1].second-a[i].second);
		dmax=max(dmax, a[0].second);
		dmax=max(dmax, h-a[n-1].second);
		ans=max(ans, dmax+w);
		dodo(0, n-1, 0, h);
		swap(w, h);
		for(i=0;i<n;i++) swap(a[i].first, a[i].second);
	}
	cout<<ans<<endl;
	return 0;
}
//*/

Measured memory_bytes: 26204