program atcoder
    implicit none
    integer(8) :: i,j,k,wmax,n
    integer(8),allocatable,dimension(:) :: dp1,dp2
    integer(8),allocatable,dimension(:) :: w,v

    read*,n,wmax
    allocate(dp1(0:100000))
    allocate(dp2(0:100000))
    allocate(w(0:n))
    allocate(v(0:n))
    do i=1,n
        read*,w(i),v(i)
    enddo

    !dp(value) := minimum weight
    dp1 = lshift( 1_8, 50 )
    dp2 = lshift( 1_8, 50 )
    dp1(0) = 0
    dp2(0) = 0
    do i=1,n
        do j=0,100000-v(i)
            dp2(j+v(i)) = min(dp2(j+v(i)),dp1(j)+w(i))
        enddo
        dp1 = dp2
    enddo

    do i=100000,0,-1
        if(dp1(i)<=wmax)then
            write(*,'(I0)') i
            exit
        endif
    enddo
    stop 
contains
end program atcoder
