#include <bits/stdc++.h>
using namespace std;
vector<int> in[100001];
int a[100001];
int f[302];
int main() {
  int n, m, s, e;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) {
    int x = 1;
    scanf("%d", &x);
    in[x].push_back(i);
  }
  memset(f, 63, sizeof(f));
  f[0] = 0;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 299; j >= 0; --j) {
      if (f[j] > m) continue;
      vector<int>::iterator t =
          upper_bound(in[a[i]].begin(), in[a[i]].end(), f[j]);
      if (t == in[a[i]].end()) continue;
      int x = *t;
      f[j + 1] = min(f[j + 1], x);
    }
    for (int j = 1; j <= 300; ++j) {
      int t = i + f[j];
      if (t > s) continue;
      t += j * e;
      if (t > s) continue;
      ans = max(ans, j);
    }
  }
  printf("%d\n", ans);
}
