#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,tune=native")
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <math.h>
#include <string>
#include <vector>
#include <chrono>
#include <random>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#include <set>
#define endl '\n'

using namespace std;
using i64 = long long;
using ld = long double;

const i64 INF = 1e18 + 5;

mt19937 rnd(29);

i64 gcd_ext(i64 a, i64 b, i64& x, i64& y) {
	if (b == 0) {
		x = 1; y = 0;
		return a;
	}
	i64 x1 = 0, y1 = 0;
	i64 c = gcd_ext(b, a % b, x1, y1);
	x = y1, y = (-y1 * (a / b) + x1);
	return c;
}

i64 gcd(i64 a, i64 b) {
	while (b) swap(b, a %= b);
	return a;
}

const i64 S = 3e5 + 10, K = 25;
i64 a[S], b[S];
i64 ex[S], pref[S][K], suf[S][K];
i64 prefSum[S];

i64 getSum(i64 l, i64 r) {
	return prefSum[r] - (l == 0 ? 0 : prefSum[l - 1]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	i64 n, m, t; cin >> n >> m >> t;

	for (i64 x = 0; x < n; ++x) {
		cin >> a[x];
		prefSum[x] = a[x];
		if (x > 0) prefSum[x] += prefSum[x - 1];
		for (i64 y = 1; y < K; ++y) {
			pref[x][y] = -1, suf[x][y] = -1;
		}
	}

	for (i64 x = 0; x < m; ++x) {
		cin >> b[x];
		--b[x];
		ex[b[x]] = 1;
	}
	
	for (i64 x = 0; x < n; ++x) {
		for (i64 y = 1; y < K; ++y) {
			if (x > 0) pref[x][y] = pref[x - 1][y];
		}
		pref[x][a[x]] = x;
	}

	for (i64 x = n - 1; x >= 0; --x) {
		for (i64 y = 1; y < K; ++y) {
			if (x < n - 1) suf[x][y] = suf[x + 1][y];
		}
		suf[x][a[x]] = x;
	}

	i64 ans = 0;

	for (i64 x = 0; x < n; ++x) {
		if (ex[x]) {
			ans = max(ans, t / a[x]);
			for (i64 y = 1; y < K; ++y) {
				if (pref[x][y] != -1 && pref[x][y] != x && getSum(pref[x][y] + 1, x) <= t) {
					ans = max(ans, (x - pref[x][y]) + (t - getSum(pref[x][y] + 1, x)) / y);
				}

				if (suf[x][y] != -1 && suf[x][y] != x && getSum(x, suf[x][y] - 1) <= t) {
					ans = max(ans, (suf[x][y] - x) + (t - getSum(x, suf[x][y] - 1)) / y);
				}
			}
		}
	}

	cout << ans;
}