#include <bits/stdc++.h>

#define gc( ) std::getchar( )
#define pc( i ) std::putchar( i )
#define RE cout << "Passing [" << __FUNCTION__ << "] on " << __LINE__ << '\n'
#define DEBUG(...) for( auto &i: __VA_ARGS__ ) cout << i << " "; cout << '\n'
#define space ' '
#define enter '\n'
using std::make_pair;

template < typename T >
inline T read( )
{
	register T x = 0;
	register char ch = gc( );
	register bool f = 0;
	while( !std::isdigit( ch ) )
	{
		f = ( ch == '-' );
		ch = gc( );
	}
	while( std::isdigit( ch ) )
	{
		x = x * 10 + ( ch - '0' );
		ch = gc( );
	}
	return f ? -x : x;
}

template < typename T >
void print( T x )
{
	if( x < 0 )
	{
		x = -x;
		pc( '-' );
	}
	if( x < 10 )
	{
		pc( x + 48 );
		return;
	}
	print < T > ( x / 10 );
	pc( x % 10 + 48 );
	return ;
}

namespace Solution
{
#define IOS std::ios::sync_with_stdio( false ), std::cin.tie( 0 ), std::cout.tie( 0 )
#define Rep( i, j, k ) for( int i = j; i >= k; --i )
#define rdi( ) read < int > ( )
#define rdl( ) read < long long > ( )
#define pti( i ) print < int > ( i ), putchar( space )
#define ptl( i ) print < long long > ( i ), putchar( space )
#define For( i, j, k ) for( int i = j; i <= k; ++i )
	using std::cin;
	using std::cout;
	using std::endl;
	using std::vector;
	using std::map;
	using std::queue;
	using std::deque;
	using std::set;
	using std::pair;
	const int Maxn = 304001;
	int n, h, w, ans;
	pair < int, int > s[ Maxn ];
	class SGTree
	{
	private:
	 int mx[ Maxn << 2 ], tag[ Maxn << 2 ];
	 inline int Ls( int x ) { return x << 1; }
	 inline int Rs( int x ) { return x << 1 | 1; }
	 inline void Up( int x ) { mx[ x ] = std::max( mx[ Ls( x ) ], mx[ Rs( x ) ] ); return; }
	 inline void Add( int x, int t ) { mx[ x ] += t, tag[ x ] += t; return; }
	 inline void Down( int x ) { if( tag[ x ] ) Add( Ls( x ), tag[ x ] ), Add( Rs( x ), tag[ x ] ), tag[ x ] = 0; return; }
	public:
  inline void clear( ) { std::memset( mx, 0, sizeof mx ), std::memset( tag, 0, sizeof tag ); };
  void Modify( int rt, int l, int r, int L, int R, int d )
	 {
	  if( L <= l && r <= R )
	   return Add( rt, d );
	  int mid = l + r >> 1;
	  Down( rt );
   if( L <= mid )
    Modify( Ls( rt ), l, mid, L, R, d );
	  if( mid < R )
	   Modify( Rs( rt ), mid + 1, r, L, R, d );
   return Up( rt );
	 }
	 int Query( )
	 {
	  return mx[ 1 ];
	 }
	}elvahs;
	int topa, topb;
 pair < int, int > a[ Maxn ], b[ Maxn ];
	void Solve( )
 {
	 std::sort( s + 1, s + 1 + n, std::less < pair < int, int > > ( ) );
	 elvahs.clear( );
	 topa = topb = 0;
	 For( i, 1, n )
	 {
	  int nxt = i - 1;
	  if( s[ i ].second <= h / 2 )
	  {
    while( topa && a[ topa ].second <= s[ i ].second )
     elvahs.Modify( 1, 1, n, a[ topa ].first, nxt, a[ topa ].second - s[ i ].second ),
				 nxt = a[ topa-- ].first - 1;
				if( nxt != i - 1 )
				 a[ ++topa ] = make_pair( nxt + 1, s[ i ].second );
	  }
	  else
	  {
    while( topb && b[ topb ].second >= s[ i ].second )
     elvahs.Modify( 1, 1, n, b[ topb ].first, nxt, s[ i ].second - b[ topb ].second ),
				 nxt = b[ topb-- ].first - 1;
				if( nxt != i - 1 )
				 b[ ++topb ] = make_pair( nxt + 1, s[ i ].second );
	  }
	  a[ ++topa ] = make_pair( i, 0 );
   b[ ++topb ] = make_pair( i, h );
   elvahs.Modify( 1, 1, n, i, i, h - s[ i ].first );
   ans = std::max( ans, s[ i + 1 ].first + elvahs.Query( ) );
	 }
	}
 void Fakemain( )
	{
	 IOS;
  cin >> w >> h >> n;
  For( i, 1, n )
   cin >> s[ i ].first >> s[ i ].second;
  s[ ++n ] = make_pair( 0, 0 );
  s[ ++n ] = make_pair( w, h );
  Solve( );
  For( i, 1, n )
   std::swap( s[ i ].first, s[ i ].second );
  std::swap( h, w );
  Solve( );
  cout << ans * 2;
		return;
	}

} // namespace Solution

int main( int argc, char* argv[] )
{
	Solution::Fakemain( );
	return 0;
}

Measured memory_bytes: 17444