#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, m, k; cin >> n >> m >> k;
	long long a[n], b[m];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if(i > 0) a[i] += a[i-1];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
		if(i > 0) b[i] += b[i-1];
	}

	int res = upper_bound(b, b + m, k) - b;
	for (int i = 0; i < n; i++)
	{
		if(a[i] > k) break;
		int id = upper_bound(b, b + m, k - a[i]) - b;
		res = max(res, i + id + 1);
	}
	cout << res << endl;
	return 0;
}
