import numpy as np

def main():

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

  a=np.array(list(map(int,input().split())))

  b=np.array(list(map(int,input().split())))

  a=np.cumsum(a)

  b=np.cumsum(b)

  k+=1

  a0=np.searchsorted(a,k)

  b0=np.searchsorted(b,k)

  if a0>b0:

    r=a0

  else:

    r=b0

  for i in range(a0):

    k0=k-a[i]

    b0=np.searchsorted(b,k0)

    b0+=i+1

    if b0 > r:

      r=b0

  print(r)

main()
import numpy as np



def main():

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

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

  b=np.array(list(map(int,input().split())))

  b=np.cumsum(b)

  k0=k+1

  b0=np.searchsorted(b,k0)

  r=b0

  i=0

  for i, ia in enumerate(a):

    k0=k0-ia

    if k0<=0:

      break

    b0=np.searchsorted(b,k0)

    b0+=i+1

    if b0 > r:

      r=b0

  print(r)

main()
import numpy as np


def main():
    n, m, k = list(map(int, input().split()))
    a = np.array(list(map(int, input().split())))
    b = np.array(list(map(int, input().split())))
    a = np.cumsum(a)
    b = np.cumsum(b)
    k += 1
    a0 = np.searchsorted(a, k)
    b0 = np.searchsorted(b, k)
    if a0 > b0:
        r = a0
    else:
        r = b0
    for i in range(a0):
        k0 = k - a[i]
        b0 = np.searchsorted(b, k0)
        b0 += i + 1
        if b0 > r:
            r = b0
    print(r)


main()

import numpy as np


def main():
    n, m, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = np.array(list(map(int, input().split())))
    b = np.cumsum(b)
    k0 = k + 1
    b0 = np.searchsorted(b, k0)
    r = b0
    i = 0
    for i, ia in enumerate(a):
        k0 = k0 - ia
        if k0 <= 0:
            break
        b0 = np.searchsorted(b, k0)
        b0 += i + 1
        if b0 > r:
            r = b0
    print(r)


main()

-    a = np.array(list(map(int, input().split()))) +    a = list(map(int, input().split())) -    a = np.cumsum(a) -    k += 1 -    a0 = np.searchsorted(a, k) -    b0 = np.searchsorted(b, k) -    if a0 > b0: -        r = a0 -    else: -        r = b0 -    for i in range(a0): -        k0 = k - a[i] +    k0 = k + 1 +    b0 = np.searchsorted(b, k0) +    r = b0 +    i = 0 +    for i, ia in enumerate(a): +        k0 = k0 - ia +        if k0 <= 0: +            break