#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
vector<int> u[100005];
int main() {
  int n, m, s, e;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  vector<int> a(n), b(m), dp(1);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    u[b[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    vector<int> go(1);
    vector<int>& v = u[a[i]];
    auto t = v.begin();
    for (int j = 0; j < int(dp.size()); j++) {
      if (t != v.end() && *t < dp[j]) t = lower_bound(t + 1, v.end(), dp[j]);
      if (t == v.end() || *t + i + (j + 1) * e + 2 > s) break;
      go.push_back(*t + 1);
    }
    dp.resize(max(dp.size(), go.size()), INF);
    for (size_t j = 0; j < go.size(); j++) dp[j] = min(dp[j], go[j]);
  }
  printf("%d\n", dp.size() - 1);
}
