#include <bits/stdc++.h>
using namespace std;
template <class T>
void pv(T a, T b) {
  for (T i = a; i != b; ++i) cout << *i << " ";
  cout << endl;
}
int pd[310][100100];
int a[100100];
vector<int> ls[100100];
int main() {
  int n, m, s, e;
  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)++) {
    int b;
    scanf("%d", &b);
    ls[b].push_back(i);
  }
  for (int(i) = (0); (i) < (100100); (i)++) sort(ls[i].begin(), ls[i].end());
  int km = s / e;
  int qmax = 0;
  for (int j = 0; j < n; j++) {
    if (ls[a[j]].size())
      pd[1][j] = ls[a[j]][0];
    else
      pd[1][j] = -1;
    if (j &&
        (pd[1][j] == -1 || (pd[1][j - 1] != -1 && pd[1][j] > pd[1][j - 1])))
      pd[1][j] = pd[1][j - 1];
    if (pd[1][j] != -1 && e + (j + 1) + (pd[1][j] + 1) <= s) qmax = 1;
  }
  for (int i = 2; i < km + 1; i++) {
    for (int j = 0; j < n; j++) {
      if (j == 0) {
        pd[i][0] = -1;
      } else {
        pd[i][j] = -1;
        if (pd[i - 1][j - 1] != -1 && ls[a[j]].size() > 0) {
          int pos =
              upper_bound(ls[a[j]].begin(), ls[a[j]].end(), pd[i - 1][j - 1]) -
              ls[a[j]].begin();
          if (pos >= 0 && pos < ls[a[j]].size()) {
            pd[i][j] = ls[a[j]][pos];
          }
        }
        if (pd[i][j] == -1 || (pd[i][j - 1] != -1 && pd[i][j] > pd[i][j - 1]))
          pd[i][j] = pd[i][j - 1];
      }
      if (i > qmax && pd[i][j] != -1 && i * e + (j + 1) + (pd[i][j] + 1) <= s)
        qmax = i;
    }
  }
  printf("%d\n", qmax);
  return 0;
}
