#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 10, M = 300 + 10;
int a[N], dp[N][M];
vector<int> p[N];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = (0); i <= (n - 1); i++) cin >> a[i];
  for (int i = (1); i <= (m); i++) {
    int x;
    cin >> x;
    p[x].emplace_back(i);
  }
  int ans = 0;
  for (int i = (0); i <= (s / e); i++) dp[0][i] = i * (m + 1);
  for (int i = (1); i <= (n); i++) {
    for (int j = (1); j <= (s / e); j++) {
      auto it = upper_bound((p[a[i - 1]]).begin(), (p[a[i - 1]]).end(),
                            (j == 1 ? 0 : dp[i - 1][j - 1]));
      dp[i][j] = dp[i - 1][j];
      if (it != p[a[i - 1]].end()) {
        dp[i][j] = min(dp[i][j], *it);
        if (s - e * j >= i + dp[i][j]) ans = max(ans, j);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
