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

const int N = 300000 + 10;

struct Point {
	int x, y;
	Point(){}
	Point( int x, int y ):x(x),y(y){}
};
bool cmp_y( const Point &r, const Point &s ) {
	return r.y < s.y;
}

struct Node;
void modify( Node *nd, int lf, int rg, int L, int R, int delta );
struct Node {
	int vmax;
	int flag;
	void pushdown( int lf, int rg ) {
		if( flag ) {
			int mid = (lf + rg) >> 1;
			modify( ls, lf, mid, lf, mid, flag );
			modify( rs, mid+1, rg, mid+1, rg, flag );
			flag = 0;
		}
	}
	void update() {
		vmax = max( ls->vmax, rs->vmax );
	}
	Node *ls, *rs;
}pool[N*2], *tail=pool, *root;

int n, H, W;
int disc[N], dtot;
int ltop, rtop;
Point pts[N];
Point lstk[N], rstk[N];

Node *build( int lf, int rg ) {
	Node *nd = ++tail;
	if( lf == rg ) {
		nd->vmax = W - disc[lf];
	} else {
		int mid = (lf + rg) >> 1;
		nd->ls = build( lf, mid );
		nd->rs = build( mid+1, rg );
		nd->flag = 0;
		nd->update();
	}
	return nd;
}
void modify( Node *nd, int lf, int rg, int L, int R, int delta ) {
	if( L <= lf && rg <= R ) {
		nd->vmax += delta;
		nd->flag += delta;
		return;
	}
	int mid = (lf + rg) >> 1;
	nd->pushdown(lf,rg);
	if( L <= mid )
		modify( nd->ls, lf, mid, L, R, delta );
	if( R > mid ) 
		modify( nd->rs, mid+1, rg, L, R, delta );
	nd->update();
}
int query( Node *nd, int lf, int rg, int L, int R ) {
	if( L <= lf && rg <= R ) {
		return nd->vmax;
	}
	int mid = (lf + rg) >> 1;
	nd->pushdown(lf,rg);
	if( R <= mid )
		return query( nd->ls, lf, mid, L, R );
	else if( L > mid )
		return query( nd->rs, mid+1, rg, L, R );
	else 
		return max( query( nd->ls, lf, mid, L, R ),
			query( nd->rs, mid+1, rg, L, R ) );
}
void print( Node *nd, int lf, int rg ) {
	if( lf == rg ) {
		printf( "%d(%d) ", disc[lf], nd->vmax );
		return;
	}
	int mid = (lf + rg) >> 1;
	nd->pushdown(lf,rg);
	print( nd->ls, lf, mid );
	print( nd->rs, mid+1, rg );
	nd->update();
}

int solve() {
//	printf( "n = %d W = %d H = %d\n", n, W, H );

	sort( pts+1, pts+1+n, cmp_y );
//	for( int i = 1; i <= n; i++ )
//		printf( "%d %d\n", pts[i].x, pts[i].y );

	dtot = 0;
	disc[++dtot] = 0;
	disc[++dtot] = H;
	for( int i = 1; i <= n; i++ )
		disc[++dtot] = pts[i].y;
	sort( disc+1, disc+1+dtot );
	dtot = unique( disc+1, disc+1+dtot ) - disc - 1;
	for( int i = 1; i <= n; i++ )
		pts[i].y = lower_bound( disc+1, disc+1+dtot, pts[i].y ) - disc;
	tail = pool;
	root = build( 1, dtot );
	int M = W>>1;
	int ans = 0;
	ltop = rtop = 0;
	for( int i = 1; i <= n; i++ ) {
		Point &p = pts[i];
		if( p.y == 1 ) continue;
		int s = query( root, 1, dtot, 1, p.y - 1 );
		ans = max( ans, (disc[p.y] + s)<<1 );
//		print(root,1,dtot);
//		printf( "\n" );
//		printf( "y = %d ans = %d\n", disc[p.y], ans );
		if( p.x <= M ) {
			int i;
			for( i = ltop; i >= 1; i-- ) {
				if( i == ltop )
					modify( root, 1, dtot, lstk[i].y, p.y - 1, -p.x );
				else
					modify( root, 1, dtot, lstk[i].y, lstk[i+1].y - 1, -(p.x - lstk[i+1].x) );
				if( lstk[i].x > p.x ) break;
			}
			if( i == 0 ) {
				if( ltop == 0 )
					modify( root, 1, dtot, 1, p.y - 1, -p.x );
				else
					modify( root, 1, dtot, 1, lstk[1].y - 1, -(p.x - lstk[1].x) );
			}
			lstk[ltop = i + 1] = p;
		} else {
			int i;
			for( i = rtop; i >= 1; i-- ) {
				if( i == rtop )
					modify( root, 1, dtot, rstk[i].y, p.y - 1, p.x - W );
				else
					modify( root, 1, dtot, rstk[i].y, rstk[i+1].y - 1, p.x - rstk[i+1].x );
				if( rstk[i].x < p.x ) break;
			}
			if( i == 0 ) {
				if( rtop == 0 ) 
					modify( root, 1, dtot, 1, p.y - 1, p.x - W );
				else
					modify( root, 1, dtot, 1, rstk[1].y - 1, p.x - rstk[1].x );
			}
			rstk[rtop = i + 1] = p;
		}
	}
	int s = query( root, 1, dtot, 1, dtot - 1 );
	ans = max( ans, (s + H)<<1 );
//	printf( "y = %d ans = %d\n", disc[dtot], ans );
	for( int i = 1; i <= n; i++ )
		pts[i].y = disc[pts[i].y];
	return ans;
}

int main() {
	scanf( "%d%d%d", &W, &H, &n );
	for( int i = 1; i <= n; i++ ) 
		scanf( "%d%d", &pts[i].x, &pts[i].y );
	int ans1, ans2, ans3;
	ans1 = solve();
	swap( W, H );
	for( int i = 1; i <= n; i++ )
		swap( pts[i].x, pts[i].y );
	ans2 = solve();
	ans3 = max( H, W ) * 2 + 2;
//	printf( "%d %d %d\n", ans1, ans2, ans3 );
	printf( "%d\n", max(max(ans1,ans2),ans3) );
}



Measured memory_bytes: 21120