import bisect

from itertools import accumulate



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

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

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

ans = 0

for i, a in enumerate(A):

    if a > k:

        break

    j = bisect.bisect_right(B, k-a)-1

    temp = i+j

    ans = max(ans, temp)

print(ans)
from itertools import accumulate

import bisect



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

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

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

ans = 0

for i, a in enumerate(A):

  if a > k:

    break

  temp = i + bisect.bisect_right(B, k-a)-1

  ans = max(ans, temp)

print(ans)
import bisect
from itertools import accumulate

n, m, k = list(map(int, input().split()))
A = list(accumulate([0] + list(map(int, input().split()))))
B = list(accumulate([0] + list(map(int, input().split()))))
ans = 0
for i, a in enumerate(A):
    if a > k:
        break
    j = bisect.bisect_right(B, k - a) - 1
    temp = i + j
    ans = max(ans, temp)
print(ans)

from itertools import accumulate
import bisect

n, m, k = list(map(int, input().split()))
A = [0] + list(accumulate(list(map(int, input().split()))))
B = [0] + list(accumulate(list(map(int, input().split()))))
ans = 0
for i, a in enumerate(A):
    if a > k:
        break
    temp = i + bisect.bisect_right(B, k - a) - 1
    ans = max(ans, temp)
print(ans)

+from itertools import accumulate -from itertools import accumulate -A = list(accumulate([0] + list(map(int, input().split())))) -B = list(accumulate([0] + list(map(int, input().split())))) +A = [0] + list(accumulate(list(map(int, input().split())))) +B = [0] + list(accumulate(list(map(int, input().split())))) -    j = bisect.bisect_right(B, k - a) - 1 -    temp = i + j +    temp = i + bisect.bisect_right(B, k - a) - 1