#include <iostream>
#include <vector>
#include <list>
#include <chrono>

using namespace std;
using namespace std::chrono;

struct pamti {
	int XOsa;
	int YOsa;
};

int tabela[1000][1000];
vector<pamti> koordinate;

static bool vectorContains(pamti a, int Size) {
	for (int i = 0; i < Size; i++) {
		pamti trenutna = koordinate[i];
		if (trenutna.XOsa == a.XOsa && trenutna.YOsa == a.YOsa)
			return true;
	}
	return false;
}

int main()
{
	int n, m, k, a, b, broj = 0, t = 0, koordinateSize = 0;
	cin >> n >> m >> k;
	for (int i = 0; i < k; i++) {
		cin >> a >> b;
		tabela[a - 1][b - 1] = 1;
	}
	auto start = high_resolution_clock::now();
	for (int i = 0; i < n; i++) {
		int j = 0;
		for (; j < m; j++) {
			int p = i, l = j;
			if (tabela[i][j] == 1 || tabela[i][j] == 2)
				continue;
			else {
				pamti trenutna;
				while (tabela[i][j] == 0) {
					tabela[i][j] = 2;
					if (tabela[i + 1][j] == 0 && i + 1 < n) {
						trenutna.XOsa = i + 1;
						trenutna.YOsa = j;
						if (!vectorContains(trenutna, koordinateSize)) {
							koordinate.push_back(trenutna);
							koordinateSize++;
						}
					}
					if (tabela[i - 1][j] == 0 && i - 1 > 0) {
						trenutna.XOsa = i - 1;
						trenutna.YOsa = j;
						if (!vectorContains(trenutna, koordinateSize)) {
							koordinate.push_back(trenutna);
							koordinateSize++;
						}
					}
					if (tabela[i][j + 1] == 0 && j + 1 < m) {
						trenutna.XOsa = i;
						trenutna.YOsa = j + 1;
						if (!vectorContains(trenutna, koordinateSize)) {
							koordinate.push_back(trenutna);
							koordinateSize++;
						}
					}
					if (tabela[i][j - 1] == 0 && j - 1 > 0) {
						trenutna.XOsa = i;
						trenutna.YOsa = j - 1;
						if (!vectorContains(trenutna, koordinateSize)) {
							koordinate.push_back(trenutna);
							koordinateSize++;
						}						
					}
					if (koordinateSize > t) {
						pamti sledeca = koordinate[t];
						i = sledeca.XOsa;
						j = sledeca.YOsa;
						t++;
					}
				}
				broj++;
			}
			i = p; j = l;
		}
	}
	cout << broj << endl;
	auto stop = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start);
	cout << duration.count() << endl;

	return 0;
}