#include <bits/stdc++.h>
#define pb push_back
#define mid(l, r) ((l)+(r))/2
#define len(a) (a).length()
#define sz(a) (a).size()
#define xx first
#define yy second
#define ll long long 			//-+ 9,223,372,036,854,775,807  = 9.2*10^18 = 2^63 - 1
#define ull unsigned long long	// +18,446,744,073,709,551,615  = 1.8*10^19 = 2^64 - 1
#define l long					//-+ 			 2,147,483,647	= 2.1*10^9  = 2^31 - 1
#define ul unisgned long		// +			 4,294,967,295	= 4.3*10^9	= 2^32 - 1
#define db double
#define ldb long double
#define ff(i,n) for(int (i) = 0; i < (n); ++i)
#define fff(i,a,b) for(int (i) = (a); (i)<=(b); ++i)
#define ffb(i,a,b) for(int (i) = a; i >= b; --i)
using namespace std;
 
l m[10000][10000],pos[10000][10000];
 
l promenax[]={0,  -1,  0, 1};
l promenay[]={0,- 1,  0 , 1};            
 
l broj,r,c,k,nesx,nesy;
 
bool prov(l i,l j){           
  return (0<=i && i<r && 0<=j && j<c);
}
 
void dfs(l i,l j){              
  broj++;                 
  pos[i][j]=1;                   
  ff(k,4){             
   		 l x=i+promenax[k],y=j+promenay[k];                            
   		 if(prov(x,y) && !pos[x][y] && m[x][y]==1){     
			dfs(x,y);                     
   			 }
  }
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); 
	 
    cin>>r>>c>>k;
    ff(i,r){
      ff(j,c)
       m[i][j]=1;
    }
    ff(i,k){
  	  cin>>nesx>>nesy;
  	  m[nesx-1][nesy-1]=0;
  }
 
  l res=0;
  ff(i,r){
    ff(j,c){
      if(!pos[i][j] && m[i][j]==1){
        broj=0;      
        dfs(i,j);
        if(broj>1)res++;                  
      }
    }    
  }
 
  cout<<res;
  return 0;
}