#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
	
	unsigned long int K;
	int M,N,boja=0;
	scanf("%lu %lu %d",&N,&M,&K);
	int a[N][M],i,j,k,br;
	int x,y;
	for(i=0;i<K;i++){
		scanf("%d %d",&x,&y);
		a[x][y]=0;
	}
	
	for(i=0;i<N;i++)
		for(j=0;j<M;j++){
			if(a[i][j]!=0){
				if(i==0 && j==0){
					boja++;
					a[i][j]=boja;
				}
				else if(i==0){
					if(a[i][j-1]==0){
						boja++;
					a[i][j]=boja;
					}
					else{
						a[i][j]=a[i][j-1];
					}
				}
				else if(j==0){
					if(a[i-1][j]==0){
						boja++;
					a[i][j]=boja;
					}
					else{
						a[i][j]=a[i-1][j];
					}
				}
				else{
					if(a[i][j-1]==0 && a[i-1][j]==0){
						boja++;
					a[i][j]=boja;
					}else if(a[i][j-1]!=0){
						a[i][j]=a[i][j-1];
					}else if(a[i-1][j]!=0){
						a[i][j]=a[i-1][j];
					}
				}
				
				
			}
				
		}
	
	printf("%d",boja);
	return 0;
}