#include <bits/stdc++.h>

using namespace std;

#ifdef NeverBeRed
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef TurnRed
		freopen("a.in", "r", stdin);
		//freopen("a.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n, m; ll k;
	cin >> n >> m >> k;

	vector<int> a(n), b(m);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;

	vector<int> pv(2 * max(n, m) + 1, m), wv = pv, c(m);
	for (int i = 0; i < m; ++i)
		if (pv[b[i]] == m)
		{
			int x = i;
			while (pv[b[x]] == m)
			{
				pv[b[x]] = c[i]++;
				wv[b[x]] = i;
				x = (x + n) % m;
			}
		}

	auto f = [&](ll s)
	{
		int to = min((ll)n, s);
		ll ss = s;
		for (int i = 0, mi = -1; i < to; ++i)
		{
			if (++mi == m)
				mi = 0;

			int x = wv[b[mi]];
			if (wv[a[i]] != x) continue;
			int p = pv[b[mi]]; // <
			int sz = c[x];
			int pos = pv[a[i]];

			s += pos < p;
			ll t = ((ss - 1) - i) / n + 1 + p;
			ll v = t / sz;
			int r = t - v * sz;
			if (pos < sz)
				s -= v;
			s -= pos < r;
		}

		return s;
	};

	ll l = 1, r = 1e18;
	while (l < r)
	{
		ll md = (l + r) >> 1;
		if (f(md) < k)
			l = md + 1;
		else
			r = md;
	}
	cout << l << "\n";

	return 0;
}
