import java.util.Scanner;
public class Main {public static void main(String[] args){Scanner scanner = new Scanner(System.in);int N = scanner.nextInt();int V = scanner.nextInt();int v[] = new int[N+1];int w[] = new int[N+1];int s[] = new int[N+1];for(int i=1;i<=N;i++){v[i] = scanner.nextInt();w[i] = scanner.nextInt();s[i] = scanner.nextInt();}int f[][] = new int[110][110];for(int i=1;i<=N;i++)for(int j=0;j<=V;j++)for(int k=0;k<=s[i]&&k*v[i]<=j;k++)f[i][j] = Math.max(f[i][j],f[i-1][j-k*v[i]]+k*w[i]);System.out.println(f[N][V]);}
}