#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long maxn = 5e5 + 2, N = 3e6, SQ = 100, base = 800287, mod = 1e9 + 7,
                INF = 1e13 + 10, lg = 22;
const long double eps = 1e-4;
struct node {
  long long mn, mx, lazy, sum;
  node() {
    mn = mx = sum = 0;
    lazy = -1;
  }
};
node seg[4 * maxn];
long long n, p, q, r;
long long a[maxn], b[maxn], c[maxn];
vector<pair<long long, long long> > query[maxn];
inline void shift(long long v, long long s, long long e) {
  if (seg[v].lazy == -1) {
    return;
  }
  if (seg[v].lazy == -2) {
    seg[v].lazy = 0;
  }
  seg[2 * v].mn = seg[2 * v].mx = seg[2 * v + 1].mn = seg[2 * v + 1].mx =
      seg[v].lazy;
  seg[2 * v].lazy = seg[2 * v + 1].lazy = seg[v].lazy;
  seg[2 * v].sum = ((s + e) / 2 - s) * seg[v].lazy;
  seg[2 * v + 1].sum = (e - (s + e) / 2) * seg[v].lazy;
  seg[v].lazy = -1;
}
inline node merge(node a, node b) {
  node res;
  res.mn = min(a.mn, b.mn);
  res.mx = max(a.mx, b.mx);
  res.sum = a.sum + b.sum;
  return res;
}
void modify(long long l, long long r, long long val, long long v = 1,
            long long s = 0, long long e = q) {
  if (l >= e || s >= r || seg[v].mn >= val) {
    return;
  }
  if (l <= s && e <= r && seg[v].mx <= val) {
    seg[v].mx = seg[v].mn = val;
    seg[v].sum = (e - s) * val;
    seg[v].lazy = val;
    return;
  }
  shift(v, s, e);
  modify(l, r, val, 2 * v, s, (s + e) / 2);
  modify(l, r, val, 2 * v + 1, (s + e) / 2, e);
  seg[v] = merge(seg[2 * v], seg[2 * v + 1]);
}
inline void upd(long long l, long long r, long long val) { modify(l, r, val); }
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> p >> q >> r;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]--;
    if (p - 1 > a[i]) query[p - 1].push_back({b[i], c[i]});
    query[a[i]].push_back({q - 1, c[i]});
    query[a[i]].push_back({b[i], r - 1});
  }
  long long ans = 0;
  for (long long i = p - 1; i >= 0; --i) {
    for (auto t : query[i]) {
      upd(0, t.first + 1, t.second + 1);
    }
    ans += ((q * r) - seg[1].sum);
  }
  cout << ans << '\n';
}
