program main
integer N,sup_w!supはsupremum(上限)の略
integer,allocatable,dimension(:)::w,v
integer(16),allocatable,dimension(:,:)::DP
read*,N,sup_w
allocate(w(n),v(n))
allocate(DP(0:N,0:10**3*N))
do i=1,n
  read*,w(i),v(i)
end do

DP(:,:)=huge(DP)/2
DP(0,0)=0
do i=1,N
  do j=0,10**3*N
    if(j-v(i)>=0) DP(i,j)=DP(i-1,j-v(i))+w(i)
    DP(i,j)=min(DP(i,j),DP(i-1,j))
  end do
end do

do i=10**3*N,0,-1
  if(DP(N,i)<=sup_w)then
    print"(I0)",i
    exit
  endif
end do
end program main