#include <bits/stdc++.h>
using namespace std;
const int Max = 1e6 + 10;
long long mn[Max * 4], mx[Max * 4], sum[Max * 4], sz[Max * 4], lazy[Max * 4];
vector<pair<long long, pair<long long, long long> > > A;
long long Y[Max], Z[Max];
void build(long long tl = 1, long long tr = Max, long long idx = 1) {
  lazy[idx] = -1;
  sz[idx] = tr - tl;
  if (tr - tl == 1) return;
  long long mid = (tl + tr) / 2;
  build(tl, mid, idx * 2);
  build(mid, tr, idx * 2 + 1);
}
void put(long long idx, long long x) {
  mx[idx] = mn[idx] = x;
  sum[idx] = x * sz[idx];
  lazy[idx] = x;
}
void shift(long long idx) {
  if (lazy[idx] == -1) return;
  put(idx * 2, lazy[idx]);
  put(idx * 2 + 1, lazy[idx]);
  lazy[idx] = -1;
}
void upd(long long r, long long x, long long tl = 1, long long tr = Max,
         long long idx = 1) {
  if (mn[idx] >= x) return;
  if (tl >= r) return;
  if (tr <= r && mx[idx] <= x) {
    put(idx, x);
    return;
  }
  long long mid = (tl + tr) / 2;
  shift(idx);
  upd(r, x, tl, mid, idx * 2);
  upd(r, x, mid, tr, idx * 2 + 1);
  sum[idx] = sum[idx * 2] + sum[idx * 2 + 1];
  mn[idx] = min(mn[idx * 2], mn[idx * 2 + 1]);
  mx[idx] = max(mx[idx * 2], mx[idx * 2 + 1]);
}
long long get(long long l, long long r, long long x, long long tl = 1,
              long long tr = Max, long long idx = 1) {
  if (mx[idx] <= x) return 0;
  if (tr <= l || r <= tl) return 0;
  if (l <= tl && tr <= r && mn[idx] >= x) return sum[idx] - x * sz[idx];
  long long mid = (tl + tr) / 2;
  shift(idx);
  return get(l, r, x, tl, mid, idx * 2) + get(l, r, x, mid, tr, idx * 2 + 1);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  build();
  long long n, x, y, z;
  cin >> n >> x >> y >> z;
  for (long long i = 1; i <= n; i++) {
    long long X, Y, Z;
    cin >> X >> Y >> Z;
    A.push_back(make_pair(X, make_pair(Y, Z)));
  }
  sort(A.begin(), A.end());
  long long ANS = 0;
  Y[x + 1] = Z[x + 1] = 0;
  for (long long chk = x, j = n - 1; chk >= 1; chk--) {
    Y[chk] = Y[chk + 1], Z[chk] = Z[chk + 1];
    while (j >= 0 && A[j].first >= chk)
      Y[chk] = max(Y[chk], A[j].second.first),
      Z[chk] = max(Z[chk], A[j].second.second), j--;
  }
  for (long long chk = 1, j = 0; chk <= x; chk++) {
    while (j < n && A[j].first < chk) {
      upd(A[j].second.first + 1, A[j].second.second);
      j++;
    }
    if (Y[chk] < y && Z[chk] < z) {
      ANS += (z - Z[chk]) * (y - Y[chk]) - get(Y[chk] + 1, Max, Z[chk]);
    }
  }
  cout << ANS << '\n';
}
