Problem:
Score : 100 points

Problem Statement

There are N items, numbered 1, 2, \ldots, N.
For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i.

Taro has decided to choose some of the N items and carry them home in a knapsack.
The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W.

Find the maximum possible sum of the values of items that Taro takes home.

Constraints

All values in input are integers.

1 \leq N \leq 100

1 \leq W \leq 10^9

1 \leq w_i \leq W

1 \leq v_i \leq 10^3

Input

Input is given from Standard Input in the following format:

N W
w_1 v_1
w_2 v_2
:
w_N v_N

Output

Print the maximum possible sum of the values of items that Taro takes home.

Sample Input 1

3 8
3 30
4 50
5 60

Sample Output 1

90

Items 1 and 3 should be taken.
Then, the sum of the weights is 3 + 5 = 8, and the sum of the values is 30 + 60 = 90.

Sample Input 2

1 1000000000
1000000000 10

Sample Output 2

10

Sample Input 3

6 15
6 5
5 6
6 4
6 6
3 5
7 2

Sample Output 3

17

Items 2, 4 and 5 should be taken.
Then, the sum of the weights is 5 + 6 + 3 = 14, and the sum of the values is 6 + 6 + 5 = 17.

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

	import java.io.BufferedReader;
	import java.io.IOException;
	import java.io.InputStream;
	import java.io.InputStreamReader;
	import java.io.OutputStream;
	import java.io.PrintWriter;
	import java.math.BigDecimal;
	import java.math.BigInteger;
	import java.sql.Timestamp;
	import java.time.LocalDate;
	import java.time.LocalDateTime;
	import java.time.ZoneOffset;
	import java.time.format.DateTimeFormatter;
	import java.util.ArrayList;
	import java.util.Arrays;
	import java.util.BitSet;
	import java.util.Collection;
	import java.util.Collections;
	import java.util.Comparator;
	import java.util.Deque;
	import java.util.HashMap;
	import java.util.HashSet;
	import java.util.Iterator;
	import java.util.LinkedHashMap;
	import java.util.LinkedHashSet;
	import java.util.LinkedList;
	import java.util.List;
	import java.util.Map;
	import java.util.Map.Entry;
	import java.util.PriorityQueue;
	import java.util.Queue;
	import java.util.Random;
	import java.util.Scanner;
	import java.util.Set;
	import java.util.Stack;
	import java.util.StringTokenizer;
	import java.util.TreeMap;
	import java.util.TreeSet;
	import java.util.concurrent.atomic.AtomicInteger;
	import java.util.stream.IntStream;
	import java.util.stream.Stream;
	import java.util.IdentityHashMap;
				
				
	/**
	 * for competitive programming
	 * @author BrolyCode
	 * @version 1.0.0
	 */
				
	public class Main {
		
		static Random random;
		
		private static void mySort(int[] s) {
			for (int i = 0; i < s.length; ++i) {
				int j = random.nextInt(i + 1);
				int t = s[i];
				s[i] = s[j];
				s[j] = t;
			}
			Arrays.sort(s);
		}
					
		static class Pair<A,B>{
			A x;
			B y;
			
			public Pair(A x, B y) {
				this.x=x;
				this.y=y;
			}
	
		}
					
		public static void pairSort(Pair[] p,  Comparator<? super Pair> c) {
			Arrays.sort(p, c);
		}							
				
		public static void main(String[] args) {
			random = new Random(543534151132L + System.currentTimeMillis());
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			InputReader in = new InputReader(inputStream);
			PrintWriter out = new PrintWriter(outputStream);			        
			task(in,out);		        
			out.close();					
		}
	
		private static void task(InputReader in, PrintWriter out) {
			int n=in.nextInt();
			int w=in.nextInt();
			int dp[]=new int[100001];
			Arrays.fill(dp, w+1);
			dp[0]=0;
			for(int i=1;i<=n;i++) {
				int a=in.nextInt();
				int b=in.nextInt();
				for(int j=100000;j>=0;j--) {
					if(j+b<=100000 && dp[j]+a<=w) {
						dp[j+b]=Math.min(dp[j+b], dp[j]+a);
					}
				}
			}
			int ans=0;
			for(int i=100000;i>=0;i--) {
				if(dp[i]<=w) {
					ans=i;
					break;
				}
			}
			out.println(ans);
		}

		public static int gcd(int a, int b)  
		{ 
	       BigInteger b1 = BigInteger.valueOf(a); 
	       BigInteger b2 = BigInteger.valueOf(b); 
	       BigInteger gcd = b1.gcd(b2); 
	       return gcd.intValue(); 
		} 
				      
		public static long gcd(long a, long b)  
		{ 
			BigInteger b1 = BigInteger.valueOf(a); 
			BigInteger b2 = BigInteger.valueOf(b); 
			BigInteger gcd = b1.gcd(b2); 
			return gcd.longValue(); 
		} 
					
		static class InputReader {
			public BufferedReader reader;
			public StringTokenizer tokenizer;
				
			public InputReader(InputStream stream) {
				reader = new BufferedReader(new InputStreamReader(stream), 32768);
				tokenizer = null;
			}
				
			public String next() {
				while (tokenizer == null || !tokenizer.hasMoreTokens()) {
					try {
						tokenizer = new StringTokenizer(reader.readLine());
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
				return tokenizer.nextToken();
			}
				
			public int nextInt() {
				return Integer.parseInt(next());
			}
				        
			public long nextLong() {
				return Long.parseLong(next());
			}
				        
			public double nextDouble() {
				return Double.parseDouble(next());
			}
				        
			public float nextFloat() {
				return Float.parseFloat(next());
			}
				        
		}
				
	}