#include <bits/stdc++.h>
using namespace std;
long n, m, s, e, ar1[200000], ar2[200000], dp[111111][321];
set<long> ent[300000];
set<long>::iterator it;
long ans, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) cin >> ar1[i];
  for (int i = 1; i <= m; i++) {
    cin >> ar2[i];
    ent[ar2[i]].insert(i);
  }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= 300; j++) dp[i][j] = 1e9;
  dp[0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (long j = 0; j <= s / e; j++) {
      if (dp[i][j] <= m && dp[i][j] + j * e + i <= s) ans = max(ans, j);
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      t = ar1[i + 1];
      it = ent[t].upper_bound(dp[i][j]);
      if (it == ent[t].end()) continue;
      t = (*it);
      dp[i + 1][j + 1] = min(dp[i + 1][j + 1], t);
    }
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
