import itertools as it, bisect as bs

f=lambda:list(map(int,input().split()))

g=lambda:[0]+[*it.accumulate(f())]

n,m,k=f()

A,B=g(),g()

a,j=0,m

for i in range(n+1):

  t=bs.bisect(B,k-A[i])

  if t: a=max(a,i+t-1)

print(a)
from itertools import *

f=lambda:list(map(int,input().split()))

g=lambda:[0]+[*accumulate(f())]

n,m,k=f()

A,B=g(),g()

c,j=0,m

for i,a in enumerate(A):

  while j and a+B[j]>k: j-=1

  if a+B[j]<=k: c=max(c,i+j)

print(c)
import itertools as it, bisect as bs

f = lambda: list(map(int, input().split()))
g = lambda: [0] + [*it.accumulate(f())]
n, m, k = f()
A, B = g(), g()
a, j = 0, m
for i in range(n + 1):
    t = bs.bisect(B, k - A[i])
    if t:
        a = max(a, i + t - 1)
print(a)

from itertools import *

f = lambda: list(map(int, input().split()))
g = lambda: [0] + [*accumulate(f())]
n, m, k = f()
A, B = g(), g()
c, j = 0, m
for i, a in enumerate(A):
    while j and a + B[j] > k:
        j -= 1
    if a + B[j] <= k:
        c = max(c, i + j)
print(c)

-import itertools as it, bisect as bs +from itertools import * -g = lambda: [0] + [*it.accumulate(f())] +g = lambda: [0] + [*accumulate(f())] -a, j = 0, m -for i in range(n + 1): -    t = bs.bisect(B, k - A[i]) -    if t: -        a = max(a, i + t - 1) -print(a) +c, j = 0, m +for i, a in enumerate(A): +    while j and a + B[j] > k: +        j -= 1 +    if a + B[j] <= k: +        c = max(c, i + j) +print(c)