#!/usr/bin/env python3
import sys


def solve(N: int, M: int, K: int, A: "List[int]", B: "List[int]"):
    cur = sum(A)
    for i in range(N-1,-1,-1):
        if cur>K: cur -= A[i]
        else:break
    if cur==0:
        max_k = 0
        l = 0
    else:
        max_k = i+1
        l = 1
    max_pk = max_k

    p = 0
    while(p<M):
        if cur+B[p] <= K:
            cur+=B[p]
            max_k = max_pk+p+1
            p+=1
        else:
            break

    # print(cur,max_k)
    if l ==1:
        for q in range(i,-1,-1):
            cur -= A[q]
            while(p<M):
                if cur+B[p] <= K:
                    cur+=B[p]
                    max_k = max(q+p+1, max_k)
                    p+=1
                else:
                    break
    print(max_k)





    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    B = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    solve(N, M, K, A, B)

if __name__ == '__main__':
    main()
