import java.util.Scanner;
public class Main {
public static int w[],v[],s[],total;
public static int dp[];//备忘录
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n;
w = new int[10000];
v = new int[10000];
s = new int[10000];
dp = new int[1007];
n = in.nextInt();
total = in.nextInt();
for(int i = 1;i <= n;i++){
w[i] = in.nextInt();
v[i] = in.nextInt();
s[i] = in.nextInt();
}
for(int i=1;i<=n;i++){
for(int j=total;j>=1;j--){
for(int k=0;k<=s[i]&&j>=k*w[i];k++){
dp[j]=Math.max(dp[j], dp[j-k*w[i]]+k*v[i]);
}
}
}
System.out.println(dp[total]);
in.close();
}
}