#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
const int maxn = 100005;
int a[maxn];
vector<int> b[maxn];
int dp[305];
int getpos(int x, int p) {
  if (b[x].size() && b[x][0] > p) return b[x][0];
  int left = 0, right = b[x].size() - 1;
  while (left + 1 < right) {
    int mid = (left + right) >> 1;
    if (p < b[x][mid])
      right = mid;
    else
      left = mid;
  }
  if (right >= 0 && p < b[x][right]) return b[x][right];
  return -1;
}
void work() {
  int ans = 0;
  int len = s / e;
  for (int i = 1; i <= n; i++) {
    for (int j = min(len, i); j >= 1; j--) {
      int pos = getpos(a[i], dp[j - 1]);
      if (pos == -1) continue;
      dp[j] = min(dp[j], pos);
      if (e * j + i + dp[j] <= s) ans = max(ans, j);
    }
  }
  printf("%d\n", ans);
}
int main() {
  while (scanf("%d%d%d%d", &n, &m, &s, &e) == 4) {
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i < maxn; i++) b[i].clear();
    for (int i = 1; i <= m; i++) {
      int x;
      scanf("%d", &x);
      b[x].push_back(i);
    }
    memset(dp, 0x33, sizeof dp);
    dp[0] = 0;
    work();
  }
  return 0;
}
