import sys #sys.setrecursionlimit((1<<19)-1) #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') input=sys.stdin.buffer.readline N,M=map(int,input().split()) can=[tuple(map(int,input().split())) for i in range(N)] ans=0 dp=[0]*(M+1) for i in range(M+1): now=0 for a,b,c in can: if i>=a: now=max(now,(((i-a)//(a-b)+1)*c*b+dp[(i-a)%(a-b)])) dp[i]=now print(max(dp))