// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

const int N = 3e5+20 , MaxlogN = 25 , INF = 0x3f3f3f3f;

struct node { int x,y; } a[N];

int n,w,h,ans,Min[N],Max[N];

int q[N],head,tail,border;

inline void input(void)

{

    scanf("%d%d%d",&w,&h,&n);

    for (int i=1;i<=n;i++)

        scanf("%d%d",&a[i].x,&a[i].y);

}

inline void divide(int l,int r)

{

    if ( l == r ) return void();

    int mid = l + r >> 1 , y1 , y2;

    divide( l , mid ) , divide( mid+1 , r );

    y1 = 0 , y2 = h;

    for (int i=mid;i>=l;i--)

    {

        Max[i] = y1 , Min[i] = y2;

        if ( a[i].y <= border ) y1 = max( y1 , a[i].y );

        if ( a[i].y >= border ) y2 = min( y2 , a[i].y );

    }

    y1 = 0 , y2 = h;

    for (int i=mid+1;i<=r;i++)

    {

        Max[i] = y1 , Min[i] = y2;

        if ( a[i].y <= border ) y1 = max( y1 , a[i].y );

        if ( a[i].y >= border ) y2 = min( y2 , a[i].y );

    }

    head = 1 , tail = 0;

    for (int i=mid,j=mid+1;i>=l;i--)

    {

        while ( j <= r && Max[j] <= Max[i] )

        {

            while ( head <= tail && Min[q[tail]] + a[q[tail]].x <= Min[j] + a[j].x ) tail--;

            q[++tail] = j++;

        }

        while ( head < tail && Min[i] + a[q[head]].x <= Min[q[head+1]] + a[q[head+1]].x ) head++;

        ans = max( ans , 2 * ( a[q[head]].x - a[i].x + min( Min[i] , Min[q[head]] ) - Max[i] ) );

    }

    head = 1 , tail = 0;

    for (int i=mid+1,j=mid;i<=r;i++)

    {

        while ( j >= l && Max[j] <= Max[i] )

        {

            while ( head <= tail && Min[q[tail]] - a[q[tail]].x <= Min[j] - a[j].x ) tail--;

            q[++tail] = j--;

        }

        while ( head < tail && Min[i] - a[q[head]].x <= Min[q[head+1]] - a[q[head+1]].x ) head++;

        ans = max( ans , 2 * ( a[i].x - a[q[head]].x + min( Min[i] , Min[q[head]] ) - Max[i] ) );

    }

}

inline void solve(void)

{

    auto compare = [](node p1,node p2) { return p1.x < p2.x; };

    sort( a+1 , a+n+1 , compare );

    a[0] = (node){0,h/2} , a[n+1] = (node){w,h/2};

    border = h/2 , divide( 0 , n + 1 );

    for (int i=1;i<=n;i++)

        swap( a[i].x , a[i].y );

    swap( w , h );

    sort( a+1 , a+n+1 , compare );

    a[0] = (node){0,h/2} , a[n+1] = (node){w,h/2};

    border = h/2 , divide( 0 , n + 1 );

}

int main(void)

{

    input();

    ans = 2 * ( max(w,h) + 1 );

    solve();

    printf("%d\n",ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.2339026356764515x):
#include <stdio.h>

#include <algorithm>

#include <string.h>

#define il inline

#define mk make_pair

#define f first

#define s second

#define N 300004

using namespace std;



int w,h,n,ans,t1,t2;

pair<int,int> p[N],st1[N],st2[N];

int t[4*N],add[4*N];



il char gc()

{

	static char now[1<<20],*S,*T;

	if (T==S)

	{

		T=(S=now)+fread(now,1,1<<20,stdin);

		if (T==S) return EOF;

	}

	return *S++;

}



il int read()

{

	int res=0;

	char c;

	while ((c=getchar())<'0'||c>'9');

	res=(c^48);

	while ((c=getchar())>='0'&&c<='9') res=(res<<3)+(res<<1)+(c^48);

	return res;

}



il void pushdown(int k)

{

	add[k<<1]+=add[k],add[k<<1|1]+=add[k];

	t[k<<1]+=add[k],t[k<<1|1]+=add[k];

	add[k]=0;

}



il void uptqj(int k,int l,int r,int x,int y,int v)

{

	if (l>=x&&r<=y){add[k]+=v,t[k]+=v;return;}

	int mid=(l+r)>>1;

	pushdown(k);

	if (x<=mid) uptqj(k<<1,l,mid,x,y,v);

	if (y>mid) uptqj(k<<1|1,mid+1,r,x,y,v);

	t[k]=max(t[k<<1],t[k<<1|1]);

}



il void solve()

{

    sort(p+1,p+n+1),t1=t2=0;

    int i,last;

    for (i=1; i<=4*n; i++) t[i]=add[i]=0;

    

    for (i=1; i<=n; i++)

	{

        if (p[i].s<=h/2)

		{

            for (last=i-1; t1&&st1[t1].s<p[i].s; last=st1[t1--].f-1)

            	uptqj(1,1,n,st1[t1].f,last,st1[t1].s-p[i].s);

            if (last!=i-1) st1[++t1]=mk(last+1,p[i].s);

        }

		else

		{

			for (last=i-1; t2&&st2[t2].s>p[i].s; last=st2[t2--].f-1)

            	uptqj(1,1,n,st2[t2].f,last,p[i].s-st2[t2].s);

            if (last!=i-1) st2[++t2]=mk(last+1,p[i].s);

        }

        st1[++t1]=mk(i,0),st2[++t2]=mk(i,h);

        uptqj(1,1,n,i,i,h-p[i].f),ans=max(ans,t[1]+p[i+1].f);

    }

}



int main()

{

    w=read(),h=read(),n=read();

    int i;

    for (i=1; i<=n; i++) p[i].f=read(),p[i].s=read();

    p[++n]=mk(0,0),p[++n]=mk(w,h);

    

    solve();

	for (i=1; i<=n; i++) swap(p[i].f,p[i].s);

    swap(w,h),solve(),printf("%d",2*ans);

    

    return 0;

}