output_description: Print the maximum possible total value of the selected items.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N W
      w_1 v_1
      w_2 v_2
      :
      w_N v_N
attempt: 
  N,W = map(int, input().split())
  
  w = [0 for i in range(N+1)]
  v = [0 for i in range(N+1)]
  Wsum = [0 for i in range(N+1)]
  Vsum = [0 for i in range(N+1)]
  
  #品物、重み→1〜N番目
  for i in range(N):
      w[i+1],v[i+1] = map(int, input().split())
  
  for i in range(N):
      Wsum[i+1] = Wsum[i] + w[i+1]
      Vsum[i+1] = Vsum[i] + v[i+1]
  
  #i番目の品物まで含み制約W2のナップサック問題の最適解
  def nap(i,W2):
      #品物0個のときは価値は0
      if i == 0:
          return 0
      #制約0のときも価値は0
      if W == 0:
          return 0
      #w[i]がW2を超えるときはi番目の品物は不必要
      if W2 < w[i]:
          return nap(i-1,W2)
      #品物の重さ全部足して制約以下なら全部足したものが価値で良い
      if Wsum[i] <= W2:
          return Vsum[i]
          
      #i番目の品物をナップサックに入れるか入れないか
      return max( nap(i-1,W2-w[i])+v[i] , nap(i-1,W2) )
      
              
  print(nap(N,W), flush = True))
  
problem_description: Statement
  
  You have N items and a bag of strength W. The i-th item has a weight of w_i
  and a value of v_i.
  
  You will select some of the items and put them in the bag. Here, the total
  weight of the selected items needs to be at most W.
  
  Your objective is to maximize the total value of the selected items.
samples: [{"input": "4 6\n    2 1\n    3 4\n    4 10\n    3 4", "output": "11\n    \n\nThe first and third items should be selected.\n\n* * *"}, {"input": "4 6\n    2 1\n    3 7\n    4 10\n    3 6", "output": "13\n    \n\nThe second and fourth items should be selected.\n\n* * *"}, {"input": "4 10\n    1 100\n    1 100\n    1 100\n    1 100", "output": "400\n    \n\nYou can take everything.\n\n* * *"}, {"input": "4 1\n    10 100\n    10 100\n    10 100\n    10 100", "output": "0\n    \n\nYou can take nothing."}]