#![allow(non_snake_case)]

// Time complexity is O(sum_value * items.len()),
// auxiliary space is O(sum_value * items.len()).
fn knapsack_01_small_value(items: &[(u64, usize)], capacity: u64) -> usize {
    let n = items.len();
    let sum_value: usize = items.iter().map(|&(_weight, value)| value).sum();

    // dp[i][v] = min(w) for all subsets of items[..i] such that
    // whose sum of values is v and sum of weights is w.
    let mut dp: Vec<Vec<u64>> = vec![vec![std::u64::MAX; sum_value + 1]; n + 1];
    for i in 0..n + 1 {
        dp[i][0] = 0;
    }
    for i in 0..n {
        let (weight, value) = items[i];
        for v in 1..sum_value + 1 {
            dp[i + 1][v] = if value <= v && dp[i][v - value] != std::u64::MAX {
                std::cmp::min(dp[i][v], dp[i][v - value] + weight)
            } else {
                dp[i][v]
            };
        }
    }
    (0..sum_value + 1).filter(|&v| dp[n][v] <= capacity).max().unwrap()
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin = my::io::InputReader::new(stdin.lock());

    let N: usize = stdin.read();
    let W: u64 = stdin.read();
    let items: Vec<(u64, usize)> = (0..N).map(|_| {
        let value: usize = stdin.read();
        let weight: u64 = stdin.read();
        (weight, value)
    }).collect();
    println!("{}", knapsack_01_small_value(&items, W));
}

#[allow(unused_must_use)]
mod my {
    pub mod io {
        use std::io::{BufRead, ErrorKind, Result};
        use std::str::{FromStr, from_utf8};
        use std::fmt::Debug;

        pub fn read_word<R: BufRead>(r: &mut R, buf: &mut Vec<u8>)
                                              -> Result<usize> {
            let mut read = 0;
            loop {
                let (done, used) = {
                    let available = match r.fill_buf() {
                        Ok(n) => n,
                        Err(ref e) if e.kind() == ErrorKind::Interrupted => continue,
                        Err(e) => return Err(e)
                    };
                    match available.iter().position(|&x| x == b'\n' || x == b' ') {
                        Some(i) => {
                            buf.extend_from_slice(&available[..i]);
                            (true, i + 1)
                        }
                        None => {
                            buf.extend_from_slice(available);
                            (false, available.len())
                        }
                    }
                };
                r.consume(used);
                read += used;
                if done || used == 0 {
                    return Ok(read);
                }
            }
        }

        pub struct InputReader<R: BufRead> {
            reader: R,
            buf: Vec<u8>,
        }

        impl<R: BufRead> InputReader<R> {
            pub fn new(reader: R) -> InputReader<R> {
                InputReader {
                    reader: reader,
                    buf: Vec::<u8>::new(),
                }
            }

            pub fn read_word(&mut self) {
                read_word(&mut self.reader, &mut self.buf);
            }
            
            pub fn read<T>(&mut self) -> T
                where T: FromStr,
                      T::Err: Debug
            {
                self.buf.clear();
                self.read_word();
                from_utf8(&self.buf).unwrap().trim().parse().unwrap()
            }
        }
    }
}


Measured memory_bytes: 13108