@staticmethod
def c():
    (n, m, k) = map(int, sys.stdin.readline().split())
    a = ([0] + [int(x) for x in sys.stdin.readline().split()])
    b = [int(x) for x in sys.stdin.readline().split()]
    (*sa,) = itertools.accumulate(a)
    (*sb,) = itertools.accumulate(b)
    res = 0
    for i in range((n + 1)):
        r = (k - sa[i])
        if (r < 0):
            break
        res = max(res, (i + bi_r(sb, r)))
    print(res)
@staticmethod
def c():
    (n, m, k) = map(int, sys.stdin.readline().split())
    a = ([0] + [int(x) for x in sys.stdin.readline().split()])
    b = [int(x) for x in sys.stdin.readline().split()]
    (*sa,) = itertools.accumulate(a)
    (*sb,) = itertools.accumulate(b)
    res = 0
    for i in range((n + 1)):
        r = (k - sa[i])
        if (r < 0):
            break
        res = max(res, (i + bi_r(sb, r)))
    print(res)