#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, siz = 1e5 + 5;
vector<long long> pos[siz];
long long t, n, s, e, ans, m, k, a[siz], b[siz], next_to_find[siz][350];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> s >> e;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= m; i++) cin >> b[i], pos[b[i]].push_back(i);
  for (long long i = 0; i <= n; i++)
    for (long long j = 0; j <= s / e; j++) next_to_find[i][j] = 5e5;
  for (long long i = 0; i <= n; ++i) next_to_find[i][0] = 0;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= s / e; j++) {
      next_to_find[i][j] = next_to_find[i - 1][j];
      auto it = lower_bound(pos[a[i]].begin(), pos[a[i]].end(),
                            next_to_find[i - 1][j - 1] + 1);
      if (it != pos[a[i]].end() and next_to_find[i][j] > *it)
        next_to_find[i][j] = *it;
      if (j > ans and i + next_to_find[i][j] + j * e <= s) ans = j;
    }
  }
  cout << ans << endl;
}
