from itertools import accumulate

import bisect

n,m,k=list(map(int,input().split()))

a=[int(i) for i in input().split()]

b=[int(i) for i in input().split()]



A=list(accumulate(a))

B=list(accumulate(b))



ans = max(bisect.bisect_right(B,k),bisect.bisect_right(A,k))



for i in range(len(a)):

    r = (k-A[i])

    if r<0:

        break

    #print(r,bisect.bisect_left(B,r))

    #print(B[bisect.bisect_left(B,r)])

    ans=max(ans,i+1+bisect.bisect_right(B,r))

    #print(i+1,r,i+1+bisect.bisect_right(B,r))

    

for i in range(len(b)):

    r = (k-B[i])

    if r<0:

        break

    #print(r,bisect.bisect_left(B,r))

    #print(B[bisect.bisect_left(B,r)])

    ans=max(ans,i+1+bisect.bisect_right(A,r))

    #print(i+1,r,i+1+bisect.bisect_right(A,r))

    

print(ans)
from itertools import accumulate

import bisect

n,m,k=list(map(int,input().split()))

a=[int(i) for i in input().split()]

b=[int(i) for i in input().split()]



A=list(accumulate(a))

B=list(accumulate(b))

ans=bisect.bisect_right(B,k)

for i in range(len(a)):

    r = (k-A[i])

    if r<0:

        break

    #print(r,bisect.bisect_left(B,r))

    #print(B[bisect.bisect_left(B,r)])

    ans=max(ans,i+1+bisect.bisect_right(B,r))

print(ans)

from itertools import accumulate
import bisect

n, m, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = list(accumulate(a))
B = list(accumulate(b))
ans = max(bisect.bisect_right(B, k), bisect.bisect_right(A, k))
for i in range(len(a)):
    r = k - A[i]
    if r < 0:
        break
    # print(r,bisect.bisect_left(B,r))
    # print(B[bisect.bisect_left(B,r)])
    ans = max(ans, i + 1 + bisect.bisect_right(B, r))
    # print(i+1,r,i+1+bisect.bisect_right(B,r))
for i in range(len(b)):
    r = k - B[i]
    if r < 0:
        break
    # print(r,bisect.bisect_left(B,r))
    # print(B[bisect.bisect_left(B,r)])
    ans = max(ans, i + 1 + bisect.bisect_right(A, r))
    # print(i+1,r,i+1+bisect.bisect_right(A,r))
print(ans)

from itertools import accumulate
import bisect

n, m, k = list(map(int, input().split()))
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = list(accumulate(a))
B = list(accumulate(b))
ans = bisect.bisect_right(B, k)
for i in range(len(a)):
    r = k - A[i]
    if r < 0:
        break
    # print(r,bisect.bisect_left(B,r))
    # print(B[bisect.bisect_left(B,r)])
    ans = max(ans, i + 1 + bisect.bisect_right(B, r))
print(ans)

-ans = max(bisect.bisect_right(B, k), bisect.bisect_right(A, k)) +ans = bisect.bisect_right(B, k) -    # print(i+1,r,i+1+bisect.bisect_right(B,r)) -for i in range(len(b)): -    r = k - B[i] -    if r < 0: -        break -    # print(r,bisect.bisect_left(B,r)) -    # print(B[bisect.bisect_left(B,r)]) -    ans = max(ans, i + 1 + bisect.bisect_right(A, r)) -    # print(i+1,r,i+1+bisect.bisect_right(A,r))