#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <stack>
#include <bitset>
#include <string>
#include <map>
#include <queue>
using namespace std;
int    dred[8]={-1,0,1,0};
int dkolona[8]={0,-1,0,1};
int n,m,br,brmax,x,y,k;
char mat[1005][1005];
queue <int>qr,qk;
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=k;i++){
        scanf("%d%d",&x,&y);
        mat[x][y]='#';
    }
    for(int a=1;a<=n;a++){
        for(int b=1;b<=m;b++){
            br++;
            if(mat[a][b]=='.'){
                qr.push(a);
                qk.push(b);
                mat[a][b]='%';
                while(qr.size()){
                    int r=qr.front();
                    int k=qk.front();
                    for(int q=0;q<8;q++){
                    if(mat[(r+dred[q])][(k+dkolona[q])]=='.'){
                        mat[(r+dred[q])][(k+dkolona[q])]='%';
                        br++;
                        qr.push(r+dred[q]);
                        qk.push(k+dkolona[q]);
                    }
                }
                qr.pop();
                qk.pop();
                }
            }
        }
    }
    cout<<br<<endl;
    return 0;
}