N,W = gets.chomp.split.map(&:to_i)

wv = []
N.times do |i|
  w,v = gets.chomp.split.map(&:to_i)
  wv.push([w,v])
end

sum = wv.inject(0){|s,(w,v)| s+v}

dp = Array.new(N+1) { Array.new(sum+1, 10**9) }

(N+1).times do |i|
  dp[i][0] = 0
end

1.upto(N) do |i|
  w,v = wv[i-1]

  1.upto(sum) do |j|
    if j-v<0
      dp[i][j] = [dp[i-1][j], dp[i-1][0] + w].min
    else
      dp[i][j] = [dp[i-1][j], dp[i-1][j-v] + w].min
    end
  end
end

1.upto(sum) do |i|
  if dp[N][i] > W
    p i-1
    exit
  end
end
p sum
