#include <bits/stdc++.h>
using namespace std;
int n, m, a[222222], b[222222], s, k;
int f[3][2222];
vector<int> st[111111];
int found(int tp, int x) {
  if (int(st[tp].size()) == 0) return n + 1;
  int low = 0, high = int(st[tp].size()) - 1, mid;
  while (low + 1 < high) {
    mid = (low + high) / 2;
    if (x < st[tp][mid])
      high = mid;
    else
      low = mid;
  }
  if (x < st[tp][low])
    return st[tp][low];
  else if (x < st[tp][high])
    return st[tp][high];
  else
    return n + 1;
}
void init() {
  for (int i = 1; i <= n; i++) st[b[i]].push_back(i);
}
void solve() {
  int td = s / k, now = 0, next = 1, temp, t, money;
  for (int i = 0; i <= td; i++) f[now][i] = n + 1;
  f[now][0] = 0;
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j <= td; j++) f[next][j] = f[now][j];
    for (int j = 0; j <= td; j++)
      if (f[now][j] != n + 1) {
        t = found(a[i], f[now][j]);
        if (t == n + 1) continue;
        money = s - (j + 1) * k - i - t;
        if (money < 0) continue;
        f[next][j + 1] = min(f[next][j + 1], t);
      }
    temp = now;
    now = next;
    next = temp;
  }
  for (int j = td; j >= 0; j--)
    if (f[now][j] != n + 1) {
      cout << j;
      break;
    }
}
int main() {
  cin >> m >> n >> s >> k;
  for (int i = 1; i <= m; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  init();
  solve();
  return 0;
}
