#include <bits/stdc++.h>
using namespace std;
const int NMax = 101000;
int N, M, S, E, dp[3][NMax], A[NMax], B[NMax];
vector<int> F[NMax];
int main() {
  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);
    F[B[i]].push_back(i);
  }
  int p = 1, ret = 0, C = S / E + 1;
  for (int j = 1; j <= C; j++) {
    dp[1 - p][0] = 1000000000;
    for (int i = 0; i < N; i++) {
      int l = -1, r = F[A[i + 1]].size();
      while (l < r) {
        if (l + 1 == r) break;
        int mid = (l + r) >> 1;
        if (F[A[i + 1]][mid] > dp[p][i])
          r = mid;
        else
          l = mid;
      }
      if (r < F[A[i + 1]].size() && F[A[i + 1]][r] >= dp[p][i] + 1)
        dp[1 - p][i + 1] = F[A[i + 1]][r];
      else
        dp[1 - p][i + 1] = 1000000000;
    }
    for (int i = 1; i <= N; i++) {
      dp[1 - p][i] = min(dp[1 - p][i], dp[1 - p][i - 1]);
    }
    for (int i = 1; i <= N; i++)
      if ((long long)i + (long long)dp[1 - p][i] +
              (long long)j * (long long)E <=
          (long long)S)
        ret = j;
    p = 1 - p;
  }
  printf("%d\n", ret);
  getchar();
  getchar();
  return 0;
}
