#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define arr array
using namespace std;
const int e = 2e6 + 69;
const ll mod = 1e9 + 7;
ll a[e], b[e];
//beginner 1999 128
int main()
{
int n, m;
ll k;
cin >> n >> m >> k;
ll s = 0;
for(int i=1; i<=n; i++){
cin >> a[i];
s += a[i];
}
for(int i=1; i<=m; i++){
cin >> b[i];
s += b[i];
}
if(s <= k){
cout << n + m;
return 0;
}
int pos1 = 1, pos2 = 1;
a[n+1] = 1e17;
b[m+1] = 1e18;
int dem = 0;
while(k - min(a[pos1], b[pos2]) >= 0){
dem ++;
k -= min(a[pos1], b[pos2]);
if(min(a[pos1], b[pos2]) == a[pos1]){
pos1 ++;
}
else{
pos2 ++;
}
}
cout << dem;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgYXJyIGFycmF5CiAKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIApjb25zdCBpbnQgZSA9IDJlNiArIDY5Owpjb25zdCBsbCBtb2QgPSAxZTkgKyA3OwogCmxsIGFbZV0sIGJbZV07CiAKLy9iZWdpbm5lciAxOTk5IDEyOAogCiAKaW50IG1haW4oKQp7CiAgICAgaW50IG4sIG07CiAgICAgbGwgazsKICAgICBjaW4gPj4gbiA+PiBtID4+IGs7CiAgICAgbGwgcyA9IDA7CiAgICAgZm9yKGludCBpPTE7IGk8PW47IGkrKyl7CiAgICAgICAgY2luID4+IGFbaV07CiAgICAgICAgcyArPSBhW2ldOwogICAgIH0KICAgICBmb3IoaW50IGk9MTsgaTw9bTsgaSsrKXsKICAgICAgICBjaW4gPj4gYltpXTsKICAgICAgICBzICs9IGJbaV07CiAgICAgfQogICAgIGlmKHMgPD0gayl7CiAgICAgICAgY291dCA8PCBuICsgbTsKICAgICAgICByZXR1cm4gMDsKICAgICB9CiAgICAgaW50IHBvczEgPSAxLCBwb3MyID0gMTsKICAgICBhW24rMV0gPSAxZTE3OwogICAgIGJbbSsxXSA9IDFlMTg7CiAgICAgaW50IGRlbSA9IDA7CiAgICAgd2hpbGUoayAtIG1pbihhW3BvczFdLCBiW3BvczJdKSA+PSAwKXsKICAgICAgICBkZW0gKys7CiAgICAgICAgayAtPSBtaW4oYVtwb3MxXSwgYltwb3MyXSk7CiAgICAgICAgaWYobWluKGFbcG9zMV0sIGJbcG9zMl0pID09IGFbcG9zMV0pewogICAgICAgICAgICBwb3MxICsrOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBwb3MyICsrOwogICAgICAgIH0KICAgICB9CiAgICAgY291dCA8PCBkZW07Cn0=