#include <bits/stdc++.h>
using namespace std;
const int NN = 101 * 1000;
const int Max = 123 * 1000;
int A[NN], B[NN];
vector<int> G[NN];
int cur[NN], pre[NN];
bool can(int rem1, int rem2, int s, int e, int k) {
  s -= e * k;
  s -= rem1;
  s -= rem2;
  return s >= 0;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m, s, e;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  for (int i = 0; i < m; i++) scanf("%d", &B[i]), G[B[i]].push_back(i);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (((int)G[A[i]].size()) > 0) {
      pre[i] = G[A[i]][0];
      if (can(i + 1, pre[i] + 1, s, e, 1)) ans = 1;
    } else
      pre[i] = Max;
  }
  for (int k = 2; k < 301; k++) {
    int minIndex = Max;
    for (int i = 0; i < n; i++) {
      if (i > 0)
        minIndex =
            ((pre[i - 1] + 1) < (minIndex) ? (pre[i - 1] + 1) : (minIndex));
      int idx = lower_bound(G[A[i]].begin(), G[A[i]].end(), minIndex) -
                G[A[i]].begin();
      if (idx != ((int)G[A[i]].size())) {
        cur[i] = G[A[i]][idx];
        if (can(i + 1, cur[i] + 1, s, e, k)) {
          ans = k;
        }
      } else
        cur[i] = Max;
    }
    memcpy(pre, cur, sizeof(cur));
  }
  cout << ans << endl;
}
