#include <fstream>
using namespace std;
ifstream fin("energii.in");
ofstream fout("energii.out");
int d[10001];
int main()
{
int G,W,e,c,smax,i,j;
fin>>G>>W;
for(i=1;i<=10001;i++)
d[i]=-1;
smax=0;
for(i=1;i<=G;i++)
{
fin>>e>>c;
for(j=smax;j>=0;j--)
if(d[j]!=-1 && j+c<=10000)
{
if(d[j+c]<d[j]+e)
d[j+c]=d[j]+e;
if(j+c>smax)
smax=j+c;
}
}
int cost=0,profit=0;
for(i=1;i<=10001;i++)
if(d[i]>=W)
{cost=i;
profit=d[i];
break;}
if(profit>=W)
fout<<cost;
else fout<<-1;
fin.close();
fout.close();
return 0;
}