#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int MAXV = 100010;
const int MAXT = 333;
int a[MAXN], n;
int b[MAXN], m;
int s, e;
vector<int> ind[MAXV];
int p[MAXN][MAXT];
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = int(0); i <= int((MAXV)-1); ++i) ind[i].clear();
  for (int i = int(1); i <= int(n); ++i)
    scanf("%d", a + i), ind[a[i]].push_back(i);
  for (int i = int(1); i <= int(m); ++i) scanf("%d", b + i);
  int mt = s / e;
  int ans = 0;
  for (int t = int(1); t <= int(mt); ++t) p[0][t] = n + 1;
  p[0][0] = 0;
  for (int j = int(1); j <= int(m); ++j) {
    for (int t = int(0); t <= int(mt); ++t) p[j][t] = p[j - 1][t];
    for (int t = int(0); t <= int(mt - 1); ++t) {
      vector<int>::iterator it =
          lower_bound(ind[b[j]].begin(), ind[b[j]].end(), p[j - 1][t] + 1);
      if (it != ind[b[j]].end()) p[j][t + 1] = min(p[j][t + 1], *it);
    }
    for (int t = int(1); t <= int(mt); ++t) {
      int i = p[j][t];
      if (i > n) break;
      int rest = s - (i + j);
      int cnt = rest / e;
      ans = max(ans, min(cnt, t));
    }
  }
  printf("%d\n", ans);
  return 0;
}
