#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m, s, e;
  cin >> n >> m >> s >> e;
  vector<long long> a(n), b(m);
  for (auto &x : a) cin >> x;
  for (auto &x : b) cin >> x;
  const long long MAX_A = 1e5 + 5;
  vector<vector<long long>> pos(MAX_A);
  for (long long i = 0; i < m; i++) pos[b[i]].push_back(i);
  const long long MAX_OP = 3e2 + 5;
  vector<vector<long long>> dp(MAX_OP, vector<long long>(n, m));
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    dp[1][i] = ((long long)pos[a[i]].size() ? pos[a[i]][0] : m);
    if (dp[1][i] != m) {
      if ((i + 1 + dp[1][i] + 1) + e <= s) {
        res = 1;
      }
    }
  }
  for (long long cnt = 2; cnt < MAX_OP; cnt++) {
    long long cur_best = m;
    for (long long i = 0; i < n; i++) {
      long long idx =
          upper_bound(pos[a[i]].begin(), pos[a[i]].end(), cur_best) -
          pos[a[i]].begin();
      cur_best = min(cur_best, dp[cnt - 1][i]);
      if (idx == (long long)pos[a[i]].size()) continue;
      dp[cnt][i] = pos[a[i]][idx];
      if ((i + 1 + dp[cnt][i] + 1) + cnt * e <= s) {
        res = cnt;
      }
    }
  }
  cout << res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
