#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 1e5 + 5;
int memo[N][305];
int mn[N];
vector<int> pos[N];
int a[N];
int b[N];
int solve(int idx, int l) {
  if (idx < 0) return 1e7;
  if (l == 1) {
    return mn[idx];
  }
  int &res = memo[idx][l];
  if (~res) return res;
  res = 1e7;
  res = min(res, solve(idx - 1, l));
  int p = solve(idx - 1, l - 1);
  if (p < 1e9) {
    p = *lower_bound(pos[a[idx]].begin(), pos[a[idx]].end(), p + 1);
    res = min(res, p);
  }
  return res;
}
int main() {
  memset(memo, -1, sizeof memo);
  int n, m, s, e, x;
  scanf("%d %d %d %d", &n, &m, &s, &e);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d", &x);
    pos[x].push_back(i);
  }
  for (int i = 1; i <= 100000; ++i) {
    pos[i].push_back(1e9);
  }
  mn[0] = pos[a[0]][0];
  for (int i = 1; i < n; ++i) {
    mn[i] = pos[a[i]][0];
    mn[i] = min(mn[i], mn[i - 1]);
  }
  int mx = s / e;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int k = 1; k <= mx; ++k) {
      int j = solve(i, k);
      if ((i + j + 2) <= s - (k * e)) {
        ans = max(ans, k);
      }
    }
  }
  printf("%d", ans);
}
