import bisect

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

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

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

for i in range(1,len(A)):

    A[i]+=A[i-1]

for i in range(1,len(B)):

    B[i]+=B[i-1]

honn=a=bisect.bisect(B,K)

for i in range(len(A)):

    s=K-A[i]

    if s>=0:

        a=bisect.bisect(B,s)

        if i+1+a>honn:

            honn=i+1+a

print(honn)
import bisect

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

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

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

for i in range(1,N):

    A[i]+=A[i-1]



index = bisect.bisect(A,K)

for i in range(M):

    K-=B[i]

    if K>=0:

        a=bisect.bisect(A,K)

        if a+i+1>=index:

            index=a+i+1

print(index)
import bisect

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, len(A)):
    A[i] += A[i - 1]
for i in range(1, len(B)):
    B[i] += B[i - 1]
honn = a = bisect.bisect(B, K)
for i in range(len(A)):
    s = K - A[i]
    if s >= 0:
        a = bisect.bisect(B, s)
        if i + 1 + a > honn:
            honn = i + 1 + a
print(honn)

import bisect

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, N):
    A[i] += A[i - 1]
index = bisect.bisect(A, K)
for i in range(M):
    K -= B[i]
    if K >= 0:
        a = bisect.bisect(A, K)
        if a + i + 1 >= index:
            index = a + i + 1
print(index)

-for i in range(1, len(A)): +for i in range(1, N): -for i in range(1, len(B)): -    B[i] += B[i - 1] -honn = a = bisect.bisect(B, K) -for i in range(len(A)): -    s = K - A[i] -    if s >= 0: -        a = bisect.bisect(B, s) -        if i + 1 + a > honn: -            honn = i + 1 + a -print(honn) +index = bisect.bisect(A, K) +for i in range(M): +    K -= B[i] +    if K >= 0: +        a = bisect.bisect(A, K) +        if a + i + 1 >= index: +            index = a + i + 1 +print(index)