#include <bits/stdc++.h>
using namespace std;
const int N = 101001;
const int M = 100000;
const int K = 301;
int a[N], b[N];
int n, m, s, e, k;
vector<int> pos[N];
int ind[N];
int F[K][N];
int main() {
  scanf("%d %d %d %d", &n, &m, &s, &e);
  k = s / e;
  for (int i = (1); i <= (n); ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = (1); i <= (m); ++i) {
    scanf("%d", &b[i]);
    pos[b[i]].push_back(i);
  }
  for (int j = 0; j < (k + 1); ++j)
    for (int i = 0; i < (n + 1); ++i) F[j][i] = m + 1;
  int res = 0;
  for (int i = (0); i <= (n); ++i) F[0][i] = 0;
  for (int q = (1); q <= (k); ++q) {
    for (int i = (1); i <= (M); ++i) ind[i] = ((int)((pos[i]).size()));
    for (int i = (q); i <= (n); ++i) {
      int najmnInd = F[q - 1][i - 1];
      while (ind[a[i]] > 0 && pos[a[i]][ind[a[i]] - 1] > najmnInd) {
        --ind[a[i]];
      }
      F[q][i] = F[q][i - 1];
      if (ind[a[i]] < ((int)((pos[a[i]]).size())) &&
          pos[a[i]][ind[a[i]]] < F[q][i]) {
        F[q][i] = pos[a[i]][ind[a[i]]];
      }
      if (F[q][i] <= m && i + F[q][i] + q * e <= s) {
        res = max(res, q);
      }
    }
  }
  printf("%d\n", res);
}
