#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
vector<int> Bpos[100001];
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  vector<int> a(n), b(m);
  for (int i = 0; i < (int)(n); i++) scanf("%d", &a[i]);
  for (int i = 0; i < (int)(m); i++) {
    scanf("%d", &b[i]);
    Bpos[b[i]].push_back(i);
  }
  int maxN = s / e;
  int ans = 0;
  vector<pair<int, int> > dp(maxN + 1, pair<int, int>(-1, -1));
  dp[0] = pair<int, int>(s, 0);
  for (int i = 0; i < (int)(n + 1); i++)
    for (int j = (maxN + 1) - 1; j >= 0; j--) {
      if (dp[j].first < 0) continue;
      if (dp[j].first - e > 0 && i < n) {
        auto it =
            lower_bound(Bpos[a[i]].begin(), Bpos[a[i]].end(), dp[j].second);
        if (it != Bpos[a[i]].end() &&
            (dp[j + 1].second == -1 || 1 + *it < dp[j + 1].second))
          dp[j + 1] = pair<int, int>(dp[j].first - e, 1 + *it);
      }
      if (dp[j].first >= i + dp[j].second) ans = max(ans, j);
    }
  printf("%d\n", ans);
  return 0;
}
