#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
vector<int> a;
vector<int> b;
vector<int> aIndex[101000];
vector<int> bIndex[101000];
int nxt[101000];
pair<int, int> best[400];
inline int findIdx(int v, vector<int> reff) {
  int s = 0, e = reff.size() - 1;
  int ret = -1;
  while (s <= e) {
    int mid = (s + e) / 2;
    if (reff[mid] > v) {
      ret = mid;
      e = mid - 1;
    } else
      s = mid + 1;
  }
  return ret == -1 ? -1 : reff[ret];
}
int main() {
  scanf("%d %d %d %d", &n, &m, &s, &e);
  a = vector<int>(n, 0);
  b = vector<int>(m, 0);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    aIndex[a[i]].push_back(i);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &b[i]);
    bIndex[b[i]].push_back(i);
  }
  best[0] = make_pair(-1, -1);
  for (int i = 1; i <= 300; ++i) best[i] = make_pair(-1, 1000000000);
  int mxAns = s / e;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int idx = bIndex[a[i]].size() - 1;
    if ((ans + 1) * e + i > s) break;
    for (int j = ans + 1; j >= 0; --j) {
      idx = findIdx(best[j - 1].second, bIndex[a[i]]);
      if (idx == -1) continue;
      if (idx <= best[j].second) {
        best[j].first = i;
        best[j].second = idx;
        if ((i + idx + 2) + j * e <= s) ans = max(ans, j);
      }
    }
  }
  printf("%d\n", ans);
}
