#include <bits/stdc++.h>
using namespace std;
int dp[100005][305], a[100005], b[100005];
vector<int> pos[100005];
int nxt(int lo, int val) {
  int p = upper_bound(pos[val].begin(), pos[val].end(), lo) - pos[val].begin();
  if (p == pos[val].size()) return -1;
  return pos[val][p];
}
int main() {
  int n, m, second, e, i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &second);
  scanf("%d", &e);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    pos[b[i]].push_back(i);
  }
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  for (i = 0; i < 100005; i++) dp[i][0] = -1;
  int ans = 0;
  for (i = 0; i < 100005; i++) {
    if (i == n + 1) break;
    for (j = 0; j < 305; j++) {
      if (dp[i][j] == 0x3f3f3f3f) break;
      if (j * e + i + dp[i][j] + 1 <= second) ans = max(ans, j);
      if (i == n) continue;
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      int nowpos = nxt(dp[i][j], a[i]);
      if (nowpos != -1) dp[i + 1][j + 1] = min(dp[i + 1][j + 1], nowpos);
    }
  }
  printf("%d\n", ans);
  return 0;
}
