open System

let [|N;W|] = stdin.ReadLine().Split() |> Array.map int
let wv =
    [|1..N|]
    |> Array.map (fun _ -> stdin.ReadLine().Split() |> Array.map int)

wv
|> Array.scan (fun s [|w;v|] ->
    let l = Array.length s
    [|0..10000|]
    |> Array.map (fun x ->
        if x>=v then min (s.[x-v]+int64(w)) (s.[x])
        else s.[x])) ([|1..10000|] |> Array.map (fun _ -> 10000000000L) |> Array.append [|0L|])
|> fun x -> x.[N]
|> Array.mapi (fun i x -> (i,x))
|> Array.filter (fun (_,x) -> x<=int64(W))
|> Array.map (fun (i,_) -> i)
|> fun x -> x.[Array.length x - 1]
|> stdout.WriteLine