#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
inline long FastMax(long x, long y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y;
}
inline long FastMin(long x, long y) {
  return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x;
}
long IR[] = {0, -1, 0, 1, -1, -1, 1, 1};
long IC[] = {1, 0, -1, 0, 1, -1, -1, 1};
long n, m, s, e;
long A[100007 + 7];
long B[100007 + 7];
set<long> pos[100007 + 7];
long lt[100007 + 7];
int main(void) {
  long i, j, Icase, k = 0;
  scanf("%ld%ld%ld%ld", &n, &m, &s, &e);
  for (i = 1; i <= n; i++) {
    scanf("%ld", &A[i]);
  }
  for (i = 1; i <= m; i++) {
    scanf("%ld", &B[i]);
    pos[B[i]].insert(i);
  }
  long ans = 0;
  for (i = 1; i <= 100007; i++) {
    lt[i] = 1000000007;
  }
  long L = 0, ML = s / e + 1;
  for (i = 1; i <= n; i++) {
    for (j = ML; j >= 0; j--) {
      set<long>::iterator p = pos[A[i]].upper_bound(lt[j]);
      if (p == pos[A[i]].end()) continue;
      long I = *p;
      lt[j + 1] = min(lt[j + 1], I);
      if ((j + 1) * e + i + lt[j + 1] <= s) ans = max(ans, j + 1);
    }
    L = min(L, ML);
  }
  printf("%ld\n", ans);
  return 0;
}
