#include <bits/stdc++.h>
#define int long long
#define pp pop_back
#define pb push_back
#define eb emplace_back
#define nl cout "\n"
#define sp <<" "
#define spc <<" "<<
#define ff first
#define ss second
#define r0 return 0
#define INF INT_MAX
#define mod 998244353
#define MOD 1000000007
#define Yes cout << "YES" << endl
#define No cout << "NO" << endl
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vs vector<string>
#define pii pair <int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define pis pair<int,string>
#define sz size()
#define pause system("pause")
#define min3(a,b,c) min(a,min(b,c))
#define all(x) (x).begin(),(x).end()
#define deb(x) cout << #x << " - " << x << endl
using namespace std;
const int N=10000000000000009;
vector <int> v;
pair <int, int> p[N];
inline void test_case(){
int n, k;
cin >> n >> k;
for(int i=0; i<n; i++){
cin >> p[i].ff;
}
for(int i=0; i<n; i++){
cin >> p[i].ss;
}
sort(p, p+n);
int sc=0;
int ans=0;
for(int i=0; i<n; i++){
if(sc>=p[i].ff){
ans++;
sc+=p[i].ss;
}
}
cout << ans;
}
signed main () {
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int T = 1;
// cin >> T;
while(T--) {
test_case();
}
return 0;
}