#include <bits/stdc++.h>
using namespace std;
int dp[100101][301];
int b[100101];
int inf = 1000000000;
vector<int> p[100101];
int n, m, ss, e;
int find(int &x, int l, int r, int &now) {
  if (l > r) return inf;
  int mid;
  while (l != r) {
    mid = (l + r) / 2;
    if (p[now][mid] > x)
      r = mid;
    else
      l = mid + 1;
  }
  if (p[now][r] > x) return p[now][l];
  return inf;
}
int len[100101];
int main() {
  scanf("%d%d%d%d", &n, &m, &ss, &e);
  for (int i = 1; i <= n; i++) scanf("%d", b + i);
  for (int i = 0; i < m; i++) {
    int x;
    scanf("%d", &x);
    p[x].push_back(i + 1);
    len[x]++;
  }
  int ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= ss / e; j++) dp[i][j] = inf;
  inf = dp[0][0];
  for (int i = 0; i <= n; i++) dp[i][0] = 0;
  for (int j = 1; j <= ss / e; j++)
    for (int i = 1; i <= n; i++) {
      dp[i][j] = dp[i - 1][j];
      dp[i][j] = min(dp[i][j], find(dp[i - 1][j - 1], 0, len[b[i]] - 1, b[i]));
      if (dp[i][j] == inf) continue;
      if ((j * e + dp[i][j] + i <= ss) && ans < j) ans = j;
    }
  printf("%d\n", ans);
}
