#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int N, M, S, E;
signed long long A[100001], B[100001];
vector<int> SB[100001];
int dpdp[401][100001];
void solve() {
  int f, i, j, k, l, x, y;
  cin >> N >> M >> S >> E;
  for (i = 0; i < N; i++) cin >> A[i];
  for (i = 0; i < M; i++) {
    cin >> B[i];
    SB[B[i]].push_back(i);
  }
  for (x = 0; x < 301; x++)
    for (y = 0; y < 100001; y++) dpdp[x][y] = 1000000;
  for (y = 0; y < 100001; y++) dpdp[0][y] = 0;
  int ma = 0;
  for (x = 0; x < 301; x++) {
    int mi = (x > 0) ? (dpdp[x][x - 1] + 1) : 0;
    for (y = x; y < N; y++) {
      vector<int>::iterator it =
          lower_bound(SB[A[y]].begin(), SB[A[y]].end(), mi);
      if (it == SB[A[y]].end()) {
        dpdp[x + 1][y] = 1000000;
      } else {
        dpdp[x + 1][y] = *it;
        k = (x + 1) * E + (y + 1) + (*it + 1);
        if (k <= S) ma = max(ma, x + 1);
      }
      mi = min(mi, dpdp[x][y] + 1);
    }
  }
  (void)printf("%d\n", ma);
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
