N,M,K = list(map(int, input().split()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))



a, b = [0], [0]

tmp = 0

for i in range(N):

  tmp += A[i]

  a.append(tmp)

tmp = 0

for i in range(M):

  tmp += B[i]

  b.append(tmp)



total = 0

count = []

best_j = len(b)-1

for i in range(len(a)):

  if a[i] <= K:

    for j in range(best_j, -1, -1):

      total = a[i] + b[j]

      if total <= K:

        count.append(i+j)

        best_j = j

        break

if len(count) == 0:

  print((0))

else:

  print((max(count)))

    

  
N,M,K = list(map(int, input().split()))

A = list(map(int, input().split()))

B = list(map(int, input().split()))



a, b = [0], [0]

tmp = 0

for i in range(N):

  tmp += A[i]

  a.append(tmp)

tmp = 0

for i in range(M):

  tmp += B[i]

  b.append(tmp)



j = len(b)-1

ans = 0

for i in range(len(a)):

  if a[i] > K:

    break

  while a[i] + b[j] > K:

    j -= 1

  ans = max(ans, i+j)

print(ans)

    

  
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
tmp = 0
for i in range(N):
    tmp += A[i]
    a.append(tmp)
tmp = 0
for i in range(M):
    tmp += B[i]
    b.append(tmp)
total = 0
count = []
best_j = len(b) - 1
for i in range(len(a)):
    if a[i] <= K:
        for j in range(best_j, -1, -1):
            total = a[i] + b[j]
            if total <= K:
                count.append(i + j)
                best_j = j
                break
if len(count) == 0:
    print((0))
else:
    print((max(count)))

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
tmp = 0
for i in range(N):
    tmp += A[i]
    a.append(tmp)
tmp = 0
for i in range(M):
    tmp += B[i]
    b.append(tmp)
j = len(b) - 1
ans = 0
for i in range(len(a)):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)

-total = 0 -count = [] -best_j = len(b) - 1 +j = len(b) - 1 +ans = 0 -    if a[i] <= K: -        for j in range(best_j, -1, -1): -            total = a[i] + b[j] -            if total <= K: -                count.append(i + j) -                best_j = j -                break -if len(count) == 0: -    print((0)) -else: -    print((max(count))) +    if a[i] > K: +        break +    while a[i] + b[j] > K: +        j -= 1 +    ans = max(ans, i + j) +print(ans)