#include <bits/stdc++.h>
namespace fast_IO {
char buf[10000005];
int cur_p = -1, len;
inline int getch() {
  if (++cur_p >= len) {
    len = fread(buf, 1, 10000005, stdin);
    cur_p = 0;
  }
  return buf[cur_p];
}
inline long long getll() {
  long long res = 0;
  int c = getch(), f = 1;
  if (c == '-') {
    f = -1;
    c = getch();
  }
  for (; c < 48 || c > 57; c = getch())
    ;
  for (; c >= 48 && c <= 57; c = getch())
    res = (res << 3) + (res << 1) + c - 48;
  return f == 1 ? res : -res;
}
inline int getint() {
  int res = 0, c = getch(), f = 1;
  if (c == '-') {
    f = -1;
    c = getch();
  }
  for (; c < 48 || c > 57; c = getch())
    ;
  for (; c >= 48 && c <= 57; c = getch())
    res = (res << 3) + (res << 1) + c - 48;
  return f == 1 ? res : -res;
}
}  // namespace fast_IO
using fast_IO::getch;
using fast_IO::getint;
using fast_IO::getll;
using namespace std;
struct data {
  int a, b, c;
  inline void input() {
    a = getint();
    b = getint();
    c = getint();
  }
  inline bool operator<(const data &a) const { return c > a.c; }
} arr[500005];
long long pre[500005];
int mx[500005];
inline void upd(int &x, int y) {
  if (x < y) x = y;
}
int main() {
  int n = getint(), p = getint(), q = getint(), r = getint();
  for (int i = 0; i < n; i++) {
    arr[i].input();
    upd(mx[arr[i].a], arr[i].b + 1);
  }
  for (int i = p; i; i--) upd(mx[i], mx[i + 1]);
  for (int i = 1; i <= p; i++) pre[i] = pre[i - 1] + (q - mx[i]) + 1;
  sort(arr, arr + n);
  int mna = 0, mnb = 0, idx = 0;
  long long ans = 0;
  for (int i = r; i; i--) {
    while (idx < n && arr[idx].c == i) {
      upd(mna, arr[idx].a);
      upd(mnb, arr[idx].b);
      idx++;
    }
    if (mna >= p || mnb >= q) break;
    int l = mna + 1, r = p, res = mna;
    while (l <= r) {
      int m = l + r >> 1;
      if (mx[m] > mnb) {
        res = m;
        l = m + 1;
      } else
        r = m - 1;
    }
    ans += pre[res] - pre[mna] + (long long)(p - res) * (q - mnb);
  }
  printf("%lld\n", ans);
  return 0;
}
