#include <bits/stdc++.h>
const int MAXN = 5e5 + 7;
std::vector<std::pair<int, int> > d[MAXN];
long long ans = 0;
int smx[MAXN];
long long sum[MAXN];
int main(int argc, char *argv[]) {
  int n, la, lb, lc;
  scanf("%d %d %d %d", &n, &la, &lb, &lc);
  for (int i = 1; i <= n; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    smx[b] = std::max(smx[b], c);
    d[a].push_back(std::make_pair(b, c));
  }
  for (int i = lb - 1; i; i--) smx[i] = std::max(smx[i], smx[i + 1]);
  for (int i = 1; i <= lb; i++) sum[i] = sum[i - 1] + smx[i];
  int mxb = 0, mxc = 0, k = lb + 1;
  for (int i = la; i; i--) {
    for (int j = 0; j < (int)d[i].size(); j++) {
      int y = d[i][j].first, z = d[i][j].second;
      mxb = std::max(mxb, y);
      mxc = std::max(mxc, z);
      while (k > mxb + 1 && smx[k - 1] < mxc) k--;
    }
    k = std::max(mxb + 1, k);
    ans += 1LL * (lc - mxc) * (lb - k + 1) + 1LL * lc * (k - mxb - 1) -
           sum[k - 1] + sum[mxb];
  }
  printf("%lld\n", ans);
  return 0;
}
