#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
long long powmod(long long a, long long b) {
  long long tmp = 1;
  a %= (1000000007);
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a % (1000000007);
    a = a * a % (1000000007);
  }
  return tmp;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
inline void add(int &x, int y) {
  for (x += y; x >= (1000000007); x -= (1000000007))
    ;
}
vector<int> v[100001];
int n, m, s, e, ans, f[100001], a[100001], x;
int main() {
  R(n);
  R(m);
  R(s);
  R(e);
  for (int i = 1; i <= n; i++) R(a[i]);
  for (int i = 1; i <= m; i++) R(x), v[x].push_back(i);
  int lim = s / e;
  for (int i = 1; i <= lim; i++) f[i] = (1 << 29);
  for (int i = 1; i <= n; i++)
    for (int j = min(i, lim); j >= 1; j--)
      if (f[j - 1] <= m) {
        vector<int>::iterator it =
            upper_bound(v[a[i]].begin(), v[a[i]].end(), f[j - 1]);
        if (it != v[a[i]].end()) {
          f[j] = min(f[j], *it);
          if (s - e * j - (*it + i) >= 0) ans = max(ans, j);
        }
      }
  printf("%d\n", ans);
  return 0;
}
