#include <bits/stdc++.h>

using namespace std;

long long a[200005], b[200005];

int main() {
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);
	
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		a[i] += a[i - 1];
	}
	
	for (int i = 1; i <= m; i++) {
		scanf("%d", &b[i]);
		b[i] += b[i - 1];
	}
	
	int res = 0;
	int p = m;
	
	for (int i = 0; i <= n; i++) {
		while (p >= 0 && a[i] + b[p] > k) {
			p--;
		}
		
		if (a[i] + b[p] <= 1LL * k) res = max(res, i + p);
	}
	
	printf("%d\n", res);
}
