#include <iostream>
using namespace std;
int dp[101][101];
struct aaa
{
int weight;
int price;
}a[101];
int main()
{
int n,w;
while(cin>>n>>w)
{
for(int i=1;i<=n;i++) cin>>a[i].weight>>a[i].price;
for(int i=1;i<=n;i++) //第i种
{
for(int j=1;j<=w;j++)
{
int m=max(dp[i-1][j-a[i].weight]+a[i].price,dp[i-1][j]); //左:放入第i件物品,右:不放
if(a[i].weight>j) dp[i][j]=dp[i-1][j];
else dp[i][j]=m;
// cout<<dp[i][j]<<" ";
}
//cout<<endl;
}
cout<<"最大价值是:"<<dp[n][w]<<endl;
}
}
using namespace std;
int dp[101][101];
struct aaa
{
int weight;
int price;
}a[101];
int main()
{
int n,w;
while(cin>>n>>w)
{
for(int i=1;i<=n;i++) cin>>a[i].weight>>a[i].price;
for(int i=1;i<=n;i++) //第i种
{
for(int j=1;j<=w;j++)
{
int m=max(dp[i-1][j-a[i].weight]+a[i].price,dp[i-1][j]); //左:放入第i件物品,右:不放
if(a[i].weight>j) dp[i][j]=dp[i-1][j];
else dp[i][j]=m;
// cout<<dp[i][j]<<" ";
}
//cout<<endl;
}
cout<<"最大价值是:"<<dp[n][w]<<endl;
}
}