import sys
import random
import heapq
from collections import deque
input = sys.stdin.readline
def fg():
    return int(input())
def fgh():
    return [int(xx) for xx in input().split()]
def tt():
    sys.stdout.flush()
def sd():
    print('Yes')
def df():
    print('No')
n, m, T = fgh()
a = fgh()
b = fgh()
l = 0
pr = [0]
for i in range(n):
    pr.append(pr[-1] + a[i])
ans = 0
for i in range(n):
    while l < m and b[l] - 1 <= i:
        l += 1
    if l:
        if pr[i] - pr[b[l - 1] - 1] <= T:
            ans = max(ans, i - b[l - 1] + 1 + (T - pr[i] + pr[b[l - 1] - 1]) // a[i])
    if l < m:
        if pr[b[l]] - pr[i + 1] <= T:
            ans = max(ans, b[l] - i - 1 + (T - pr[b[l]] + pr[i + 1]) // a[i])
print(ans)