#include<bits/stdc++.h>
using namespace std;

// for 20 points

vector<vector<bool>> mat1;

void pretraga(int i, int j, int N, int M){
	// note in if, if you check value
    	// before you check if it is out side range
    	// you get segment dump
	if((j > N - 1 || i > M - 1) || (j < 0 || i < 0) || !mat1[i][j]){
		return;
	}
	mat1[i][j] = false;
	pretraga(i + 1, j, N, M);
	pretraga(i, j + 1, N, M);
	pretraga(i - 1, j, N, M);
	pretraga(i, j - 1, N, M);
}

int main(){
	ios_base::sync_with_stdio(false);
	int N, M, K; cin >> N >> M >> K;
	int sol = 0;

	for(int i = 0; i < M; i++){
		vector<bool> temp(N, true);
		mat1.push_back(temp);
	}
	for(int i = 0; i < K; i++){
		int x, y; cin >> x >> y;
		mat1[x-1][y-1] = false;
	}
	for(int i = 0; i < M; i++){
		for(int j = 0; j < N; j++){
			if(mat1[i][j]) sol++;
			pretraga(i, j, N, M);
		}
	}
	cout << sol << "\n";
	return 0;
}