#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
	int n,m,f,s,b,c=0,boja1,bb=2,boja2;
	 int a[1000][1000];
int boja(int k,int r)
{
	
if((a[k-1][r]!=0) && (a[k-1][r]!=1))
{
	return a[k-1][r];
	}	
if((a[k][r+1]!=0) && (a[k][r+1]!=1))	
	{
	return a[k][r+1];
	}
if((a[k+1][r]!=0)&& (a[k+1][r]!=1)	)
	{
	return a[k+1][r];
	}
if((a[k][r-1]!=0 )&& (a[k][r-1]!=1)	)
	{
	return a[k][r-1];
	}else{return 0;
	}	
}
void oboji(int w,int e)
{
	if(a[w][e]<1){
	
	boja1=boja(w,e);
	if(boja1==0)
	{
	
		a[w][e]=bb;
		bb++;
	}else
	{a[w][e]=boja1;
	
		if(w<=n && e<=m){
		
		oboji(w,e+1);
		oboji(w+1,e+1);
		oboji(w+1,e);
	}
	}
}else{

		if(w<=n && e<=m){
		
		oboji(w,e+1);
		oboji(w+1,e+1);
		oboji(w+1,e);
	}
	
}

	
	
	
}
int main(int argc, char** argv) {	
cin>>n>>m>>f;

	for(int i=0;i<f;i++)
	{
	
		cin>>s>>b;
		a[s-1][b-1]=1;
			
	}
	

		oboji(0,0);


	cout<<bb-2;
	
	
	
	return 0;
}