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]

for i in range(1,m):

    b[i] += b[i-1]

a = [0]+a

b = [0]+b



ans = 0

ALL = 0

from bisect import bisect

for i in range(n+1):

    ALL = a[i]

    if ALL > k:

        continue

    else:

        idx = bisect(b,k-ALL)

    #print(i,ALL,idx)

        ans = max(ans,i+idx-1)

print(ans)
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]

for i in range(1,m):

    b[i] += b[i-1]

a = [0]+a

b = [0]+b



ans = 0

ALL = 0

j = m



for i in range(n+1):

    if a[i] > k:

        continue

    else:

        while k-a[i] < b[j] :

            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()))
for i in range(1, n):
    a[i] += a[i - 1]
for i in range(1, m):
    b[i] += b[i - 1]
a = [0] + a
b = [0] + b
ans = 0
ALL = 0
from bisect import bisect

for i in range(n + 1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        idx = bisect(b, k - ALL)
        # print(i,ALL,idx)
        ans = max(ans, i + idx - 1)
print(ans)

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]
for i in range(1, m):
    b[i] += b[i - 1]
a = [0] + a
b = [0] + b
ans = 0
ALL = 0
j = m
for i in range(n + 1):
    if a[i] > k:
        continue
    else:
        while k - a[i] < b[j]:
            j -= 1
    ans = max(ans, i + j)
print(ans)

-from bisect import bisect - +j = m -    ALL = a[i] -    if ALL > k: +    if a[i] > k: -        idx = bisect(b, k - ALL) -        # print(i,ALL,idx) -        ans = max(ans, i + idx - 1) +        while k - a[i] < b[j]: +            j -= 1 +    ans = max(ans, i + j)