#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(const T &a) {
  return a * a;
}
int n, m, s, e, a[200000], b[200000], min1[200000], pos, ans, d[100100][310];
vector<int> c[200000];
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    c[b[i]].push_back(i + 1);
  }
  for (int j = 1; j < s / e + 1; j++) min1[j] = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = s / e; j > 0; j--) {
      pos = lower_bound(c[a[i]].begin(), c[a[i]].end(), min1[j - 1] + 1) -
            c[a[i]].begin();
      if (pos < c[a[i]].size()) {
        pos = c[a[i]][pos];
        d[i][j] = pos, min1[j] = min(min1[j], pos);
        if (i + 1 + pos + j * e <= s) ans = max(ans, j);
      }
    }
  }
  printf("%d\n", ans);
}
