#include <bits/stdc++.h>
using namespace std;
long a[201], b[201], c[201];
int dp[201][250];
int miniTrainRequired(int t, int k, int n, long a[201], long b[201],
                      long c[201]) {
  if (t == 0) return 0;
  long people[201], canCome[201], maxStation[201];
  for (int i = 0; i < n; i++) {
    people[i] = a[i];
    canCome[i] = b[i];
    maxStation[i] = c[i];
  }
  int minResult = 9999999;
  bool value = false;
  for (int i = 0; i < n; i++) {
    if (people[i] + canCome[i] > maxStation[i]) {
      value = true;
      break;
    }
  }
  if (value) {
    int result = 1;
    int peopleCantakePlace = k;
    for (int i = 0; i < n; i++) {
      if (peopleCantakePlace > 0) {
        peopleCantakePlace = peopleCantakePlace - people[i];
        people[i] -= people[i];
      } else {
        peopleCantakePlace = k;
        peopleCantakePlace = peopleCantakePlace - people[i];
        people[i] -= people[i];
        result += 1;
      }
    }
    for (int i = 0; i < n; i++) {
      people[i] += canCome[i];
    }
    return result + miniTrainRequired(t - 1, k, n, people, canCome, maxStation);
  }
  int result = 1;
  int peopleCantakePlace = k;
  for (int i = 0; i < n; i++) {
    if (peopleCantakePlace > 0) {
      peopleCantakePlace = peopleCantakePlace - a[i];
      a[i] -= a[i];
    } else {
      peopleCantakePlace = k;
      peopleCantakePlace = peopleCantakePlace - a[i];
      a[i] -= a[i];
      result += 1;
    }
  }
  for (int i = 0; i < n; i++) {
    people[i] += canCome[i];
  }
  for (int i = 0; i < n; i++) {
    a[i] += b[i];
  }
  return min(result + miniTrainRequired(t - 1, k, n, a, b, c),
             miniTrainRequired(t - 1, k, n, people, canCome, maxStation));
}
int main() {
  long long n, t, k;
  cin >> n >> t >> k;
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  cout << miniTrainRequired(t, k, n, a, b, c);
  return 0;
}
