#include <bits/stdc++.h>
using namespace std;
int N, M, S, E, T, INF, ans;
int dp[100005][305], mn[305];
int A[100005], B[100005];
vector<int> have[100005], pos[100005];
int Find(int x, int fr) {
  if (have[x].size() == 0 || have[x][have[x].size() - 1] < fr) return INF;
  return have[x][lower_bound(have[x].begin(), have[x].end(), fr) -
                 have[x].begin()];
}
int main() {
  int i, j;
  scanf("%d %d %d %d", &N, &M, &S, &E);
  for (i = 1; i <= N; i++) scanf("%d", &A[i]);
  for (i = 1; i <= M; i++) scanf("%d", &B[i]), have[B[i]].push_back(i);
  memset(dp, 62, sizeof(dp)), INF = dp[0][0];
  memset(mn, 62, sizeof(mn));
  dp[0][0] = 0, mn[0] = 0;
  for (i = 1, T = S / E; i <= N; i++)
    for (j = T; j >= 1; j--)
      if (mn[j - 1] != INF) {
        dp[i][j] = Find(A[i], mn[j - 1] + 1);
        mn[j] = min(mn[j], dp[i][j]);
      }
  for (i = 1; i <= N; i++)
    for (j = 1; j <= T; j++)
      if (dp[i][j] != INF && E * j + i + dp[i][j] <= S) ans = max(ans, j);
  printf("%d\n", ans);
  return 0;
}
