n,m,t=map(int,input().split())
A=list(map(int,input().split()))
C=list(map(int,input().split()))
dp=[[0]*(50+3) for _ in range(n+2)]
z=0
for c in C:
    if A[c-1]<=t:
        dp[c][A[c-1]]=1
        z=max(z,t//A[c-1])
for j in range(50+3):
    for i in range(1,n+1):
        if j>=A[i-1]:
            q=max([dp[i-1][j-A[i-1]],dp[i+1][j-A[i-1]],dp[i][j-A[i-1]]])
            if q>0:
                q+=1
                dp[i][j]=q
                z=max(z,q*(t//j))

print(z)
