# Tsundoku

import numpy as np

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

A = np.array([0] + list(map(int, input().split())))

B = np.array([0] + list(map(int, input().split())))

a = np.cumsum(A)

b = np.cumsum(B)



ans = 0

j = M



for i in range(N+1):

    if a[i] > K:

        break

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

        j -= 1

    ans = max(ans, i+j)

    

print(ans)
# Tsundoku

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

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

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

if M > N:

    N,M = M,N

    A,B = B,A

a = [0]

b = [0]

for _ in range(max(N, M)):

    if _ < min(N,M):

        a.append(a[_] + A[_])

        b.append(b[_] + B[_])

    else:

        a.append(a[_] + A[_])

ans = 0

j = M

for i in range(N+1):

    if a[i] > K:

        break

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

        j -= 1

    ans = max(ans, i+j)

print(ans)
# Tsundoku
import numpy as np

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

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

-import numpy as np - -A = np.array([0] + list(map(int, input().split()))) -B = np.array([0] + list(map(int, input().split()))) -a = np.cumsum(A) -b = np.cumsum(B) +A = list(map(int, input().split())) +B = list(map(int, input().split())) +if M > N: +    N, M = M, N +    A, B = B, A +a = [0] +b = [0] +for _ in range(max(N, M)): +    if _ < min(N, M): +        a.append(a[_] + A[_]) +        b.append(b[_] + B[_]) +    else: +        a.append(a[_] + A[_])