#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
long long sum, ans, suma[N], sumb[N];
int n, t1, t2, t3, maxa, maxb, maxc, mab[N], mba[N];
struct d {
  int a, b, c;
} cd[N];
bool cmp(d x, d y) { return x.c < y.c; }
void Maxi(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  scanf("%d%d%d%d", &n, &maxa, &maxb, &maxc);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d%d", &t1, &t2, &t3);
    cd[i] = (d){t1, t2, t3};
  }
  sort(cd + 1, cd + 1 + n, cmp);
  for (int i = 1; i <= n; i++) Maxi(mab[cd[i].a], cd[i].b);
  for (int i = maxa; i; i--) Maxi(mab[i], mab[i + 1]);
  for (int i = 1; i <= n; i++) Maxi(mba[cd[i].b], cd[i].a);
  for (int i = maxb; i; i--) Maxi(mba[i], mba[i + 1]);
  for (int i = 1; i <= maxb; i++) sum += maxa - mba[i];
  for (int i = 1; i <= maxa; i++) suma[i] = suma[i - 1] + maxb - mab[i];
  for (int i = 1; i <= maxb; i++) sumb[i] = sumb[i - 1] + maxa - mba[i];
  int p = n, pa = 0, pb = 0;
  for (int i = maxc; i; i--) {
    while (p && cd[p].c == i) Maxi(pa, cd[p].a + 1), Maxi(pb, cd[p].b + 1), p--;
    if (mab[pa] < pb)
      ans += 1ll * (maxa - pa + 1) * (maxb - pb + 1);
    else
      ans += sum - suma[pa - 1] - sumb[pb - 1];
  }
  printf("%lld", ans);
  return 0;
}
