#include <bits/stdc++.h>
using namespace std;
const int INF = 99999999;
const int N = 100010;
const int M = 5005;
int f[M], a[N], b[N];
vector<int> v[N];
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    v[b[i]].push_back(i);
  }
  for (int i = 0; i < N; i++) v[i].push_back(INF);
  f[0] = 0;
  for (int i = 1; i < M; i++) f[i] = INF - 1;
  int ans = 0, limit = s / e;
  for (int i = 1; i <= n; i++) {
    for (int j = limit; j > 0; j--) {
      f[j] = min(f[j], *upper_bound(v[a[i]].begin(), v[a[i]].end(), f[j - 1]));
      if (i + f[j] + e * j <= s) ans = max(ans, j);
    }
  }
  cout << ans << endl;
  return 0;
}
