#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
int a[100011];
int b[100011];
int dp[301];
vector<int> v[100011];
const int INF = 1 << 20;
void solve() {
  for (int i = 0; i < m; i++) v[b[i]].push_back(i);
  for (int i = 0; i <= 300; i++) dp[i] = INF;
  dp[0] = -1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[a[i]].empty()) continue;
    for (int j = 299; j >= 0; j--) {
      int x = upper_bound((v[a[i]]).begin(), (v[a[i]]).end(), dp[j]) -
              v[a[i]].begin();
      if (x == v[a[i]].size()) continue;
      dp[j + 1] = min(dp[j + 1], v[a[i]][x]);
      if ((j + 1) * e + i + 1 + v[a[i]][x] + 1 <= s) {
        ans = max(ans, j + 1);
      }
    }
  }
  printf("%d\n", ans);
}
void coding() {
  while (cin >> n >> m >> s >> e) {
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];
    solve();
  }
}
int main() { coding(); }
