#include <bits/stdc++.h>
#define int long long
#define taskname "main"
#define debug(a, l, r) for (int _i = l; _i <= r; _i++) cout<<(a)[_i]<<' '; cout<<'\n'
#define debug_m(a, li, lj, ri, rj) for (int _i = li; _i <= ri; _i++){for (int _j = lj; _j <= rj; _j++) cout<<(a)[_i][_j]<<' '; cout<<'\n';} cout<<'\n'
using namespace std;
const int maxN = 1e6;
int n,
w[maxN + 1],
c[maxN + 1];
struct Box
{
int l, r;
inline int w()
{
return r - l;
}
void print()
{
cout << l << ' ' << r << '\n';
}
bool operator < (const Box &other) const
{
return r - l < other.r - other.l;
}
} a[maxN + 1];
priority_queue <Box> pq;
void init()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> w[i];
for (int i = 1; i <= n; i++)
cin >> c[i];
for (int i = 1; i <= n; i++)
a[i] = {c[i], c[i] + w[i]};
sort(a + 1, a + n + 1, [](Box &x, Box &y){
return x.r < y.r;
});
// for (int i = 1; i <= n; i++)
// a[i].print();
}
void solve()
{
int tmp_w = 0;
for (int i = 1; i <= n; i++)
{
if (tmp_w > a[i].l)
{
Box b_max = pq.top();
if (tmp_w - b_max.w() <= a[i].l)
{
pq.pop();
tmp_w -= b_max.w();
}
}
pq.push(a[i]);
tmp_w += a[i].w();
}
cout << pq.size();
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
init(); solve();
}