#include <bits/stdc++.h>
using namespace std;
int best[305], a[100005], b[100005];
vector<int> ids[100005];
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (auto i = (0); i < n; i++) cin >> a[i];
  for (auto j = (0); j < m; j++) cin >> b[j], ids[b[j]].push_back(j + 1);
  for (auto& id : ids) id.push_back(333333 + 1);
  for (auto k = (1); k < 305; k++) best[k] = 333333;
  int ans = 0;
  for (auto i = (0); i < n; i++)
    for (int k = 305 - 1; k; k--) {
      best[k] = min(
          best[k], *upper_bound(begin(ids[a[i]]), end(ids[a[i]]), best[k - 1]));
      if (i + 1 + best[k] + k * e <= s) ans = max(ans, k);
    }
  cout << ans << endl;
  return 0;
}
