#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const int maxn = 100000 + 10;
int n;
int m;
int st, e;
int a[maxn];
int b[maxn];
int f[300 + 10][maxn];
set<int> s[maxn];
int lim;
int ans = 0;
int main() {
  scanf("%d%d%d%d", &n, &m, &st, &e);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    s[b[i]].insert(i);
  }
  memset(f, -1, sizeof(f));
  lim = st / e + 1;
  for (int i = 1; i <= lim; i++) {
    int gm = INF;
    for (int j = 0; j < i - 1; j++) {
      if (f[i - 1][j] != -1) gm = min(gm, f[i - 1][j]);
    }
    for (int j = i - 1; j < n; j++) {
      if (i == 1) {
        if (!s[a[j]].empty()) f[i][j] = *s[a[j]].begin();
      } else {
        if (s[a[j]].upper_bound(gm) != s[a[j]].end()) {
          f[i][j] = *s[a[j]].upper_bound(gm);
        }
        if (f[i - 1][j] != -1) gm = min(gm, f[i - 1][j]);
      }
      if (f[i][j] != -1) {
        if (st - i * e >= j + f[i][j] + 2) ans = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
