#include <bits/stdc++.h>
using namespace std;
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
template <class T1, class T2>
inline void gmax(T1 &a, T2 b) {
  if (b > a) a = b;
}
template <class T1, class T2>
inline void gmin(T1 &a, T2 b) {
  if (b < a) a = b;
}
const int N = 1e5 + 10, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int n, m, s, e;
int a[N], b[N], f[305];
vector<int> d[N];
int main() {
  while (~scanf("%d%d%d%d", &n, &m, &s, &e)) {
    for (int i = 1; i <= 1e5; ++i) d[i].clear();
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i <= m; ++i) scanf("%d", &b[i]), d[b[i]].push_back(i);
    int top = s / e;
    int ans = 0;
    for (int i = 1; i <= top; ++i) f[i] = 1e9;
    f[0] = 0;
    for (int j = 1; j <= n; ++j) {
      for (int i = top; i >= 1; --i) {
        int st = f[i - 1];
        auto it = upper_bound(d[a[j]].begin(), d[a[j]].end(), st);
        if (it == d[a[j]].end())
          ;
        else {
          if (i * e + j + *it <= s) gmax(ans, i);
          gmin(f[i], *it);
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
