#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll n, m, q, k, ans, op, x;
ll l[N], c[N], numl, numc;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m >> q >> k;
while (q--) {
cin >> op >> x;
if (op == 1) {
if (!l[x])numl++;
l[x]++;
}
else {
if (!c[x])numc++;
c[x]++;
}
}
ans = numl * m + numc * n - numl * numc;
sort(c + 1, c + m + 1);
for (int i = 1; i <= n; i++) {
ll tmp = k - l[i];
ll len = upper_bound(c + 1, c + m + 1, tmp) - lower_bound(c + 1, c + m + 1, tmp);
ans -= len;
}
cout << ans;
}