/* 
    ex2_2:Plumber2
    Acro
*/
#include <stdio.h> 

int main(void){
    int num, hp, i, j;
    scanf("%d %d", &num, &hp);
    int depth[num], coins[num], dp[num+1][hp+1];
    for (i = 0; i < num; i++)
    {
        scanf("%d %d", &coins[i], &depth[i]);
    }
    for ( j = 0; j <= hp; j++)
    {
        dp[0][j] = 0;
    }
    for ( i = 0; i < num; i++)
    {
        for ( j = 0; j <= hp; j++)
        {
            if (j < depth[i])
            {
                dp[i+1][j] = dp[i][j];
            }
            else
            {
                dp[i+1][j] = dp[i][j-depth[i]] + coins[i];
                if (dp[i+1][j] < dp[i][j])
                {
                    dp[i+1][j] = dp[i][j];
                }
                
            }
        }
    }
    printf("%d\n",dp[num][hp]);
    return 0;
}
