#include struct Card { int s, k; }; int main() { int w, h, n; std::cin.tie(0); std::ios::sync_with_stdio(false); std::cin >> w; std::cin >> h; std::cin >> n; Card* card = new Card[n]; int count = 0; int sf, kf, rs = 0, rk = 0; for (int i = 0; i < n; ++i) { std::cin >> card[i].s; std::cin >> card[i].k; for (sf = 0; sf < i; ++sf) { if (card[i].s == card[sf].s) { sf = -1; ++rk; break; } } for (kf = 0; kf < i; ++kf) { if (card[i].k == card[kf].k) { kf = -1; ++rs; break; } } if (sf < 0 && kf < 0) { --count; } else { count += (sf >= 0) ? h - 1 - sf + rs : sf; count += (kf >= 0) ? w - 1 - kf + rk : kf; } } std::cout << count << std::endl; }