#include <bits/stdc++.h>
using namespace ::std;
int n, m, s, e, ans;
int d[305];
int in1[100005];
int in2[100005];
vector<int> a[100005];
int main() {
  scanf("%d %d %d %d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) scanf("%d", &in1[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &in2[i]);
  for (int i = 1; i <= m; i++) a[in2[i]].push_back(i);
  int ma = s / e + 1;
  for (int i = 1; i <= n; i++) {
    int now = in1[i];
    for (int j = ma - 1; j >= 0; j--) {
      if (d[j] != 0 || j == 0) {
        int idx = lower_bound(a[now].begin(), a[now].end(), d[j] + 1) -
                  a[now].begin();
        if (idx != a[now].size()) {
          idx = a[now][idx];
          if (d[j + 1] == 0 || d[j + 1] > idx) d[j + 1] = idx;
          if (e * (j + 1) + i + idx <= s) ans = max(ans, j + 1);
        }
      }
    }
  }
  printf("%d", ans);
  return 0;
}
