#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int n, a1[1000000];
int s = 0;
pair<int, pair<int,int>> a[1000000];
int main(){
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int ans = 0;
cin >> n;
cin >> s;
for (int i = 0; i < n; ++i)
{
cin >> a[i].second.first;
}
for (int i = 0; i < n; ++i)
{
cin >> a[i].second.second;
}
for (int i = 0; i < n; ++i)
{
a[i].first = (a[i].second.second - a[i].second.first);
}
sort(a, a + n);
for (int i = n- 1; i >= 0; --i)
{
// cout << s << endl;
s -= a[i].second.first;
if (s <= 0)
{
continue;
}
s += a[i].second.second;
ans++;
}
cout << ans;
return 0;
}
Copy