#include <bits/stdc++.h>
using namespace std;
set<int> st[110000];
int a[110000];
int b[110000];
int f[110000][400];
const int INF = 12345678;
int main() {
  ios::sync_with_stdio(false);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    st[b[i]].insert(i);
  }
  int ans = 0;
  int upper = s / e + 1;
  for (int i = 0; i <= n; i++) fill(f[i], f[i] + upper, INF);
  f[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    f[i][0] = 0;
    for (int j = 1;; j++) {
      f[i][j] = f[i - 1][j];
      int p = f[i - 1][j - 1];
      set<int>::iterator it = st[a[i]].lower_bound(p + 1);
      if (it != st[a[i]].end()) f[i][j] = min(f[i][j], *it);
      if (j * e + i + f[i][j] <= s)
        ans = max(ans, j);
      else
        break;
    }
  }
  cout << ans << "\n";
  return 0;
}
