#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100000 + 7;
const int INF = 0x3f3f3f3f;
int A[MAX_N];
int dp[300 + 7][MAX_N];
vector<int> rd[MAX_N];
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++) {
    int x;
    scanf("%d", &x);
    rd[x].push_back(i);
  }
  for (int i = 0; i < MAX_N; i++) rd[i].push_back(INF);
  memset(dp, 0x3f, sizeof(dp));
  memset(dp[0], 0, sizeof(dp[0]));
  for (int i = 1; i < 300 + 7; i++) {
    for (int j = 1; j <= N; j++) {
      if (dp[i - 1][j - 1] != INF) {
        dp[i][j] = dp[i][j - 1];
        int p = *lower_bound(rd[A[j]].begin(), rd[A[j]].end(),
                             dp[i - 1][j - 1] + 1);
        dp[i][j] = min(dp[i][j], p);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < 300 + 7; i++) {
    for (int j = i; j <= N; j++) {
      if (dp[i][j] != INF && (j + dp[i][j]) + i * E <= S) {
        ans = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
