'use strict'
const lines = require('fs').readFileSync(0, 'utf8').split('\n')
const firstLine = lines[0].split(' ').map(Number)
const N = firstLine[0]
const W = firstLine[1]
var dp = new Array(N + 1);
for(var i = 0; i < N + 1; i++){
  dp[i] = new Array(W + 1).fill(0);
}

for (let i=0;i < N;i++) {
  const vw = lines[i].split(' ')
  for (let w=0; w<W; w++) {
    if (w - vw[0] >= 0) {
      dp[i+1][w] = dp[i][w-vw[0]] + vw[1]
    }
    dp[i+1][w] = dp[i][w]
  }
}
console.log(dp[N][W])