#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, t1 = 0, k, k1, i, j, p, m, x = 0;
  cin >> n >> t >> k;
  int a[3][1000] = {0};
  for (i = 0; i < n; ++i) {
    cin >> a[0][i] >> a[1][i] >> a[2][i];
  }
  while (t1 < t) {
    m = 0;
    for (j = n; j >= 0; j--)
      if (a[0][j] + (t - t1) * a[1][j] > a[2][j]) break;
    for (i = 0; i < n; i++) {
      m = 0;
      for (p = 0; p <= j; p++) m = m + a[0][p];
      if (a[0][i] + a[1][i] > a[2][i] || (m >= k && t1 != t - 1)) {
        k1 = k;
        for (p = 0; p < n; p++) {
          if (a[0][p] <= k1) {
            k1 -= a[0][p];
            a[0][p] = 0;
          } else {
            a[0][p] -= k1;
            k1 = 0;
            break;
          }
        }
        x++;
      }
    }
    t1++;
    for (i = 0; i < n; i++) a[0][i] += a[1][i];
  }
  cout << x;
  return 0;
}
