#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int Minf = 0x7f7f7f7f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const long long MINF = 0x7f7f7f7f7f7f7f7fll;
const int N = 207;
int n, t;
long long sa[N], sb[N], c[N], a[N], b[N], k;
long long f[N][N][2], g[N][N][2];
long long up(long long x, long long y) { return (x + y - 1) / y; }
int main() {
  scanf("%d%d%lld", &n, &t, &k);
  for (int i = (1); i <= n; ++i) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
  ++n;
  a[n] = Minf;
  b[n] = Minf;
  c[n] = INF;
  for (int i = (1); i <= n; ++i)
    sa[i] = sa[i - 1] + a[i], sb[i] = sb[i - 1] + b[i];
  memset(f, 0x3f, sizeof f);
  memset(g, 0x3f, sizeof g);
  for (int i = (0); i <= t; ++i)
    for (int o = (0); o <= 1; ++o) f[0][i][o] = g[0][i][o] = 0;
  for (int i = (1); i <= n; ++i)
    for (int j = (0); j <= t; ++j)
      for (int o = (0); o <= 1; ++o) {
        if (o * a[i] + j * b[i] <= c[i] && f[i - 1][j][o] < INF) {
          f[i][j][o] = min(f[i][j][o], f[i - 1][j][o]);
          long long need = up(o * sa[i - 1] + j * sb[i - 1], k);
          if (need * k <= o * sa[i] + j * sb[i])
            g[i][j][o] = min(g[i][j][o], need);
        }
        for (int r = (0); r < j; ++r)
          if (g[i][r][o] < INF) {
            long long res = o * sa[i] + r * sb[i] - k * g[i][r][o];
            long long need = up(max(0ll, res + (j - r) * b[i] - c[i]), k);
            if (need * k <= res && f[i - 1][j - r][0] < INF) {
              f[i][j][o] =
                  min(f[i][j][o], g[i][r][o] + need + f[i - 1][j - r][0]);
              long long need2 = up((j - r) * sb[i - 1], k);
              if (need2 * k <= (j - r) * b[i] + res - need * k)
                g[i][j][o] = min(g[i][j][o], g[i][r][o] + need + need2);
            }
          }
      }
  printf("%lld\n", f[n][t][1]);
}
