#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m, s, e, mx, ans = 0;
long long a[N], b[N], dp[305], ndp[305];
set<long long> pos[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> s >> e;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= m; i++) {
    cin >> b[i];
    pos[b[i]].insert(i);
  }
  mx = s / e;
  for (long long i = 1; i <= mx; i++) dp[i] = 1e9;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= mx; j++) ndp[j] = dp[j];
    for (long long j = 1; j <= mx; j++) {
      long long idx = dp[j - 1];
      auto it = pos[a[i]].upper_bound(idx);
      if (it != pos[a[i]].end()) {
        ndp[j] = min(ndp[j], *it);
        long long left = s - e * j;
        if (left >= i + *it) ans = max(ans, j);
      }
    }
    for (long long j = 0; j <= mx; j++) dp[j] = ndp[j];
  }
  cout << ans;
  return 0;
}
