#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100, INFTY = 0x3f3f3f3f;
int A[MAXN], B[MAXN];
vector<int> p[MAXN];
int posb[330];
int resp[330];
int main() {
  int N, M, S, E;
  posb[0] = 0;
  resp[0] = 0;
  for (int i = 1; i <= 300; i++) {
    posb[i] = MAXN;
    resp[i] = INFTY;
  }
  scanf("%d %d %d %d", &N, &M, &S, &E);
  for (int i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (int i = 1; i <= M; i++) {
    scanf("%d", &B[i]);
    p[B[i]].push_back(i);
  }
  int limite = 0;
  for (int k = 1; k <= N; k++) {
    int x = A[k];
    for (int i = limite; i >= 0; i--) {
      int ini = posb[i] + 1;
      int tam = p[x].size();
      int prox = (lower_bound(&p[x][0], &p[x][tam], ini) - &p[x][0]);
      if (prox == tam) continue;
      posb[i + 1] = min(posb[i + 1], p[x][prox]);
      resp[i + 1] = min(resp[i + 1], p[x][prox] + k);
      if (i == limite && i < 299) limite++;
    }
  }
  int ans = 0;
  for (int i = 0; i <= 300; i++) {
    int qq = E, rr = S;
    qq *= i;
    qq += resp[i];
    if (E * i + resp[i] > S) break;
    ans = i;
  }
  printf("%d\n", ans);
  return 0;
}
