#include <bits/stdc++.h>
using namespace std;
const long long maxn = 210;
const long long INF = 1e18;
long long n, t, k, a[maxn], b[maxn], c[maxn], sa[maxn], sb[maxn],
    f[maxn][maxn][2], g[maxn][maxn][2];
signed main() {
  scanf("%lld%lld%lld", &n, &t, &k);
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
  ++n;
  a[n] = c[n] = INF;
  for (long long i = (1), _end_ = (n); i <= _end_; ++i) {
    sa[i] = sa[i - 1] + a[i];
    sb[i] = sb[i - 1] + b[i];
  }
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    for (long long j = (0), _end_ = (t); j <= _end_; ++j)
      for (long long o = (0), _end_ = (1); o <= _end_; ++o)
        f[i][j][o] = g[i][j][o] = INF;
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    for (long long j = (0), _end_ = (t); j <= _end_; ++j)
      for (long long o = (0), _end_ = (1); o <= _end_; ++o) {
        if (j * b[i] + o * a[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 x = (sb[i - 1] * j + sa[i - 1] * o + k - 1) / k;
          if (x * k <= sb[i] * j + sa[i] * o) g[i][j][o] = min(g[i][j][o], x);
        }
        for (long long r = (0), _end_ = (j - 1); r <= _end_; ++r) {
          if (g[i][r][o] == INF) continue;
          long long num = sa[i] * o + sb[i] * r - k * g[i][r][o];
          long long x = max(0ll, (num + (j - r) * b[i] - c[i] + k - 1) / k);
          if (k * x > num || f[i - 1][j - r][0] == INF) continue;
          f[i][j][o] = min(f[i][j][o], g[i][r][o] + x + f[i - 1][j - r][0]);
          long long y = (sb[i - 1] * (j - r) + k - 1) / k;
          if (k * y <= (j - r) * sb[i] + num - k * x)
            g[i][j][o] = min(g[i][j][o], g[i][r][o] + x + y);
        }
      }
  printf("%lld\n", f[n][t][1]);
  return 0;
}
