#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, m, q, k;
cin >> n >> m >> q >> k;
map<int, int> row, col;
while(q -- ) {
int op, x;
cin >> op >> x;
if(op == 1) {
row[x] ++ ;
if(row[x] >= k) row[x] -= k;
}
else {
col[x] ++ ;
if(col[x] >= k) col[x] -= k;
}
}
ll ans = 0, sum = 0;
vector<int> hh(k + 1);
for(auto [num, cnt] : col) {
if(cnt != 0) sum ++ ;
hh[cnt] ++ ;
}
for(auto [num, cnt] : row) {
if(cnt == 0) ans += sum;
else ans += m - hh[k - cnt];
}
for(auto [num, cnt] : col) {
if(cnt != 0) ans += n - row.size();
}
cout << ans << '\n';
return 0;
}