You are trying to get your monsters to participate in the upcoming Monster Koshien. In the Monster Koshien, there will be several opposing monsters, and you will play against them one-on-one in turn. Whether you win or not, you can move on to the next match. In a match, the three values of speed, strength, and cleverness of the opposing monsters are compared, and the monster with two or more of these values higher wins.
You can adjust the numerical value of your monster to gain an advantage against your opponent's monster. For each gold coin you pay, you can increase the value of one of the three numbers by one size. In exchange, you must decrease the value of one of the other two values by one. The number can be increased as much as you want, but it must be increased or decreased in a non-negative way. The number can be adjusted before each game, and it does not matter how many gold coins you spend. As long as you have gold coins, you can adjust your numbers. The increased or decreased values will be carried over to subsequent matches.You are getting information about your opponent's monsters and thinking how to play your own monsters.
You are given the numerical value of each of your monsters, the numerical value of each of the monsters they will face before the match, the order in which they will face each other, and the number of gold coins you can spend. Create a program that calculates the maximum number of matches that your monster will win.
The input is given in the following format.
$N$ $C$ $a$ $s$ $w$ $a_1$ $s_1$ $w_1$ : $a_N$ $s_N$ $w_N$
The first line gives you the number of matches $N$ ($1 \leq N \leq 50$) and the number of gold coins $C$ ($1 \leq C \leq 5000$) that you can spend. The next line will give you the speed ($0 \leq a \leq 100$), strength ($0 \leq s \leq 100$), and cleverness ($0 \leq w \leq 100$) of your monster. The following $N$ lines give the speed ($0 \leq a_i \leq 100$), strength ($0 \leq s_i \leq 100$), and cleverness ($0 \leq w_i \leq 100$) of the $i$th monster to fight.
Output the maximum number of matches your monster will win.
2 22 10 30 50 30 100 10 20 50 50
2
3 30 30 30 0 70 25 20 25 30 60 20 25 90
2