#include <cstdio>
#include <cstring>
using namespace std;

const int N = 1005;

struct E{
    int m, l, k;
} e[N];

int del[N], cnt[N], T, n;
bool check(int u){
    memset(cnt, 0, sizeof(cnt));
    memset(del, 0, sizeof(del));
    cnt[0] = u;
    int t, i;
    for(t = 0; t <= T; ++t) if(cnt[t]){
        for(i=1;i<=n;++i) if(!del[i] && t%(e[i].l+e[i].k)<=e[i].l){
            if(t+e[i].m > T) return 0;
            cnt[t+e[i].m]++;
            del[i] = 1;
            cnt[t]--;
            if(!cnt[t]) break;
        }
        cnt[t+1] += cnt[t];
    }
    for(i=1;i<=n;++i) if(!del[i]) return 0;
    return 1;
}

int main(){
    int i;
    while(scanf("%d%d",&n,&T)&&(n+T)){
        for(i=1;i<=n;++i)
            scanf("%d%d%d",&e[i].m, &e[i].l, &e[i].k);
        //int l = 1, r = n;
        for(i=1;i<=n;++i) if(check(i)) break;
        printf("%d\n", i);
    }
    return 0;
}