Operator
The customer telephone support center of the computer sales company called JAG is now incredibly confused. There are too many customers who request the support, and they call the support center all the time. So, the company wants to figure out how many operators needed to handle this situation.
For simplicity, let us focus on the following simple simulation.
Let N be a number of customers. The i-th customer has id i, and is described by three numbers, M_i, L_i and K_i. M_i is the time required for phone support, L_i is the maximum stand by time until an operator answers the call, and K_i is the interval time from hanging up to calling back. Let us put these in other words: It takes M_i unit times for an operator to support i-th customer. If the i-th customer is not answered by operators for L_i unit times, he hangs up the call. K_i unit times after hanging up, he calls back.
One operator can support only one customer simultaneously. When an operator finish a call, he can immediately answer another call. If there are more than one customer waiting, an operator will choose the customer with the smallest id.
At the beginning of the simulation, all customers call the support center at the same time. Thesimulation succeeds if operators can finish answering all customers within T unit times.
Your mission is to calculate the minimum number of operators needed to end this simulation successfully.
Input
The input contains multiple datasets. Each dataset has the following format:
N T M_1 L_1 K_1 ... M_N L_N K_N
The first line of a dataset contains two positive integers, N and T (1 ≤ N ≤ 1000, 1 ≤ T ≤ 1000). N indicates the number of customers in the dataset, and T indicates the time limit of the simulation.
The following N lines describe the information of customers. The i-th line contains three integers, M_i, L_i and K_i (1 ≤ M_i ≤ T, 1 ≤ L_i ≤ 1000, 1 ≤ K_i ≤ 1000), describing i-th customer’s information. M_i indicates the time required for phone support, L_i indicates the maximum stand by time until an operator answers the call, and K_i indicates the is the interval time from hanging up to calling back.
The end of input is indicated by a line containing two zeros. This line is not part of any dataset and hence should not be processed.
Output
For each dataset, print the minimum number of operators needed to end the simulation successfully in a line.