#include <bits/stdc++.h>
using namespace std;
template <typename... As>
struct tpl : public std::tuple<As...> {
  using std::tuple<As...>::tuple;
  template <typename T = tuple<As...>>
  typename tuple_element<0, T>::type const& x() const {
    return get<0>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<0, T>::type& x() {
    return get<0>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<1, T>::type const& y() const {
    return get<1>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<1, T>::type& y() {
    return get<1>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<2, T>::type const& z() const {
    return get<2>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<2, T>::type& z() {
    return get<2>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<3, T>::type const& w() const {
    return get<3>(*this);
  }
  template <typename T = tuple<As...>>
  typename tuple_element<3, T>::type& w() {
    return get<3>(*this);
  }
};
using lli = long long int;
using vi = vector<lli>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  lli n, x1, y1, z1;
  cin >> n >> x1 >> y1 >> z1;
  vi fx(x1 + 1, y1), fy(y1 + 1, x1);
  vector<tuple<lli, lli, lli>> A;
  for (lli i = 0; i < (lli)(n); ++i) {
    lli x, y, z;
    cin >> x >> y >> z;
    fx[x] = min(fx[x], y1 - y);
    fy[y] = min(fy[y], x1 - x);
    A.push_back(make_tuple(z, x, y));
  }
  sort(begin(A), end(A));
  reverse(begin(A), end(A));
  for (lli x = (x1 - 1); x >= (lli)(0); --x) fx[x] = min(fx[x], fx[x + 1]);
  for (lli y = (y1 - 1); y >= (lli)(0); --y) fy[y] = min(fy[y], fy[y + 1]);
  lli x0 = 1, y0 = 1;
  lli ans = 0;
  for (auto const& a : A) {
    lli x, y, z;
    tie(z, x, y) = a;
    if (x < x0 && y < y0) continue;
    lli dx = 0, dy = 0;
    for (lli xx = (x0); xx <= (lli)(x); ++xx) {
      dx += min(fx[xx], y1 - y0 + 1);
    }
    for (lli yy = (y0); yy <= (lli)(y); ++yy) {
      dy += min(fy[yy], x1 - x0 + 1);
    }
    ans += (z1 - z) * (dx + dy);
    x0 = max(x0, x + 1);
    y0 = max(y0, y + 1);
  }
  ans += (x1 - x0 + 1) * (y1 - y0 + 1) * z1;
  cout << ans << endl;
  return 0;
}
