#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 1e6 + 10;
int n, m, s, e;
vector<int> g[N];
int dp[N], a[N];
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) {
    int t;
    scanf("%d", &t);
    g[t].push_back(i);
  }
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 0;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = s / e; j >= 0; --j) {
      auto t = upper_bound(g[a[i]].begin(), g[a[i]].end(), dp[j]);
      if (t == g[a[i]].end()) continue;
      dp[j + 1] = min(dp[j + 1], *t);
      if (dp[j + 1] + i + e * (j + 1) <= s) ans = max(ans, j + 1);
    }
  }
  printf("%d\n", ans);
}
