#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int Szukaj(vector<int>& a, int x) {
  if (a.size() == 0) return -1;
  int l = 0, p = a.size() - 1, s, r = -1;
  while (l <= p) {
    s = (l + p) / 2;
    if (a[s] >= x) {
      r = s;
      p = s - 1;
    } else
      l = s + 1;
  }
  return r;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  vector<int> a(n);
  vector<vector<int> > b(100000);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    b[x - 1].push_back(i);
  }
  vector<vector<int> > dp(301, vector<int>(n, INF));
  for (int i = 0; i < n; ++i)
    if (b[a[i]].size() != 0) dp[1][i] = b[a[i]][0];
  for (int i = 2; i <= 300; ++i) {
    int pier = INF;
    for (int j = 0; j < n; ++j) {
      if (j != 0) pier = min(pier, dp[i - 1][j - 1]);
      if (pier != INF) {
        int nast = Szukaj(b[a[j]], pier + 1);
        if (nast != -1) dp[i][j] = b[a[j]][nast];
      }
    }
  }
  int odp = 0;
  for (int i = 1; i <= 300; ++i)
    for (int j = 0; j < n; ++j)
      if (dp[i][j] != INF && e * i + (j + 1) + (dp[i][j] + 1) <= s)
        odp = max(odp, i);
  cout << odp;
  return 0;
}
