#include <bits/stdc++.h>
using namespace std;
int dp[500], a[100005], b[100005];
vector<int> c[100005];
inline int findL(int x, int y) {
  int L = 0, R = (int)c[x].size() - 1;
  if (R == -1) return 1000000005;
  while (L + 1 < R) {
    int mid = (L + R) >> 1;
    if (c[x][mid] > y)
      R = mid;
    else
      L = mid;
  }
  if (c[x][L] > y) return c[x][L];
  if (c[x][R] > y) return c[x][R];
  return 1000000005;
}
int main() {
  int n, m, s, e;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    c[b[i]].push_back(i);
  }
  int tim = s / e, ans = 0;
  for (int i = 1; i <= tim; i++) dp[i] = 1000000005;
  dp[0] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = tim; j >= 0; j--) {
      if (dp[j] == 1000000005) continue;
      if (s - j * e >= i - 1 + dp[j]) ans = max(ans, j);
      int pos = findL(a[i], dp[j]);
      dp[j + 1] = min(dp[j + 1], pos);
      if (s - (j + 1) * e >= i + dp[j + 1]) ans = max(ans, j + 1);
    }
  printf("%d\n", ans);
  return 0;
}
