#include <bits/stdc++.h>
using namespace std;
int array1[100006], array2[100006];
int dp[100006][306];
set<pair<int, int> > Set;
int prep(int N, int M, int S, int E) {
  int maxstep = S / E + 1;
  int n, m, k;
  set<pair<int, int> >::iterator is;
  bool f;
  Set.clear();
  for (m = 1; m <= M; ++m) Set.insert(make_pair(array2[m], m));
  int ans = 0, temp, cost;
  if (maxstep > ((N) < (M) ? (N) : (M))) maxstep = ((N) < (M) ? (N) : (M));
  for (n = 1; n <= N; ++n) {
    dp[n][0] = 0;
    for (k = 1; k <= maxstep; ++k) {
      dp[n][k] = dp[n - 1][k];
      if (k > 1 && dp[n - 1][k - 1] == 0) continue;
      is = Set.upper_bound(make_pair(array1[n], dp[n - 1][k - 1]));
      if (is == Set.end() || is->first != array1[n]) continue;
      temp = is->second;
      if (dp[n][k] == 0 || temp < dp[n][k]) dp[n][k] = temp;
      if (dp[n][k]) {
        cost = k * E + n + dp[n][k];
        if (cost <= S && k > ans) ans = k;
      }
    }
  }
  return ans;
}
int main() {
  int N, M, S, E;
  int n, m;
  while (scanf("%d %d %d %d", &N, &M, &S, &E) != EOF) {
    for (n = 1; n <= N; ++n) scanf("%d", &array1[n]);
    for (m = 1; m <= M; ++m) scanf("%d", &array2[m]);
    printf("%d\n", prep(N, M, S, E));
    break;
  }
  return 0;
}
