#include<bits/stdc++.h>
#define N 10000
using namespace std;
int maze[N][N]={0};
int main(){
int a,b,c,x,y;
int count=0,flag;
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
cin>>a>>b>>c;
while(c--){
count++;
flag=1;
cin>>x>>y;
for(int i=0;i<8;i++){
if(x+dx[i]>0&&x+dx[i]<=a&&y+dy[i]>0&&y+dy[i]<=b){
if(maze[x+dx[i]][y+dy[i]]!=0&&flag==1){
flag=0;
count--;
}
maze[x+dx[i]][y+dy[i]]++;
}
}
}
cout<<count<<'\n';
}