#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int main()
{
int n, k = 0;
long long int s;
cin >> n >> s;
pair<int, int> *rt = new pair<int, int>[n];
for (int i = 0; i < n; i++)
{
cin >> rt[i].first;
}
for (int i = 0; i < n; i++)
{
cin >> rt[i].second;
}
sort(rt, rt + n);
for (int i = 0; i < n; i++)
{
s -= rt[i].first;
if (s > 0)
{
k++;
s += rt[i].second;
}
else
{
cout << k << endl;
return 0;
}
}
cout << k << endl;
return 0;
}