#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 7;
long long dp[maxn][307];
long long a[maxn], b[maxn];
vector<long long> pos[maxn];
long long ans = 0;
int32_t main() {
  long long n, m, s, e, i;
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> s >> e;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
    pos[b[i]].push_back(i);
  }
  for (i = 0; i < n; i++) {
    if (pos[a[i]].size() > 0) {
      dp[i][1] = pos[a[i]][0];
      if (e + i + dp[i][1] + 2 <= s) ans = max(ans, 1ll);
    }
  }
  for (long long j = 2; j <= s / e; j++) {
    long long mi = 1e9;
    for (i = 0; i < n; i++) {
      if (mi != 1e9) {
        long long x = mi;
        auto it = upper_bound(pos[a[i]].begin(), pos[a[i]].end(), x);
        if (it != pos[a[i]].end()) {
          dp[i][j] = *it;
          if (j * e + i + dp[i][j] + 2 <= s) ans = max(ans, j);
        }
      }
      if (dp[i][j - 1] != -1) {
        mi = min(mi, dp[i][j - 1]);
      }
    }
  }
  cout << ans << endl;
}
