#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 * 1000 + 10;
const int maxn5 = 5 * 1000 * 100 + 10;
const int maxn3 = 1000 + 10;
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1LL * 2 * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 10;
int dp[2][maxn3], a[maxn5];
vector<int> av[maxn5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    int b;
    cin >> b;
    av[b].push_back(i);
  }
  for (int i = 0; i < maxn5; i++) av[i].push_back(maxn);
  fill(dp[1], dp[1] + maxn3, maxn);
  dp[0][0] = -1;
  dp[1][0] = -1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 300; j++) {
      int x = maxn;
      if (dp[(i + 1) % 2][j - 1] < maxn)
        x = av[a[i]][upper_bound(av[a[i]].begin(), av[a[i]].end(),
                                 dp[(i + 1) % 2][j - 1]) -
                     av[a[i]].begin()];
      if (j * e + i + x + 2 > s) x = maxn;
      dp[i % 2][j] = min(dp[(i + 1) % 2][j], x);
      if (dp[i % 2][j] < maxn) ans = max(ans, j);
    }
  }
  cout << ans << endl;
  return 0;
}
