#include <bits/stdc++.h>
const int inf = 100100;
const int maxn = (int)1e5 + 10;
const int mod = (int)1e9 + 7;
using namespace std;
int n, m, second, e;
vector<int> g[100100];
int ind[100100];
int dp[100100];
int d[100100];
int b[100100];
int a[100100];
void solve() {
  cin >> n >> m >> second >> e;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int j = 1; j <= m; j++) {
    cin >> b[j];
  }
  for (int j = 1; j <= m; j++) {
    g[b[j]].push_back(j);
  }
  int ans = 0;
  for (int i = 1; i <= second / e; i++) {
    int cur = (i == 1) ? 0 : m + 1;
    for (int j = 1; j < 100100; j++) {
      ind[j] = g[j].size();
    }
    for (int j = 1; j <= n; j++) {
      int &h = ind[a[j]];
      while (h > 0 && g[a[j]][h - 1] > cur) {
        h--;
      }
      cur = min(cur, dp[j]);
      if (h < g[a[j]].size()) {
        dp[j] = g[a[j]][h];
        if (j + dp[j] + i * e <= second) {
          ans = i;
        }
      } else
        dp[j] = m + 1;
    }
  }
  cout << ans << "\n";
}
int main() {
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
