#include <bits/stdc++.h>
using namespace std;
int a[110000];
int b[110000];
int d[110000][310];
vector<int> v[110000];
const int INF = 1000000000;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < m; j++) {
    cin >> b[j];
    v[b[j]].push_back(j);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 300; j++) {
      if (j > 0)
        d[i][j] = INF;
      else
        d[i][j] = -1;
    }
  for (int i = 0; i < n; i++)
    if (i == 0) {
      if (v[a[i]].size() > 0)
        d[i][1] = v[a[i]][0];
      else
        d[i][1] = INF;
    } else {
      for (int j = 1; j <= 300; j++) {
        d[i][j] = d[i - 1][j];
        if (d[i - 1][j - 1] != INF) {
          int l = -1;
          int r = v[a[i]].size();
          while (r - l > 1) {
            int mid = (r + l) / 2;
            if (v[a[i]][mid] > d[i - 1][j - 1])
              r = mid;
            else
              l = mid;
          }
          if (r != v[a[i]].size()) d[i][j] = min(d[i][j], v[a[i]][r]);
        }
      }
    }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= 300; j++)
      if (d[i][j] < INF && d[i][j] != -1) {
        if (j * e + i + 1 + d[i][j] + 1 <= s) ans = max(ans, j);
      }
  cout << ans;
  return 0;
}
