def f(c,t):
    if t==0 or c==-1 or c==n:
        return 0
    if A[c]<=t:
        return 1+max([f(c-1,t-A[c]),f(c+1,t-A[c]),f(c,t-A[c])])
    return 0
    

n,m,t=map(int,input().split())
A=list(map(int,input().split()))
C=list(map(int,input().split()))
z=0
for c in C:
    z=max(z,f(c-1,t))
print(z)
    
