#include <bits/stdc++.h>
using namespace std;
long long int Pow(long long int a, long long int b, long long int md,
                  long long int ans = 1) {
  for (; b; b >>= 1, a = a * a % md)
    if (b & 1) ans = ans * a % md;
  return ans % md;
}
const long long int MAXN = 1e5 + 10;
const long long int INF = 8e18;
const long long int MAXM = 350;
const long long int MOD = 1e9 + 7;
long long int dp[MAXN][MAXM], A[MAXN], B[MAXN], n, m, s, e;
vector<long long int> pos[MAXN];
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &s, &e);
  for (long long int i = 1; i <= n; i++) scanf("%lld", &A[i]);
  for (long long int i = 1; i <= m; i++)
    scanf("%lld", &B[i]), pos[B[i]].push_back(i);
  if (e > s) return !printf("%lld\n", 0LL);
  dp[1][0] = 0;
  if ((long long int)pos[A[1]].size())
    dp[1][1] = pos[A[1]][0];
  else
    dp[1][1] = INF;
  for (long long int i = 2; i <= s / e; i++) dp[1][i] = INF;
  long long int mn = 0;
  for (long long int j = 1; j <= s / e; j++) {
    mn = dp[1][j - 1];
    for (long long int i = 2; i <= n; i++) {
      auto it = upper_bound((pos[A[i]]).begin(), (pos[A[i]]).end(), mn);
      if (it == pos[A[i]].end())
        dp[i][j] = INF;
      else
        dp[i][j] = *it;
      mn = min(mn, dp[i][j - 1]);
    }
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= s / e; j++) {
      if (dp[i][j] != INF && dp[i][j] != 0) {
        if (e * j + i + dp[i][j] <= s) {
          ans = max(ans, j);
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
