#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;
const int MX = 100010;
int n, m, s, e;
int a[MX], b[MX];
int right_a[MX], right_b[MX];
int dp[MX];
int main() {
  cin >> n >> m >> s >> e;
  for (int i = 0; i < (int)n; i++) cin >> a[i];
  for (int i = 0; i < (int)m; i++) cin >> b[i];
  set<pair<int, int> > bs;
  map<int, int> pos;
  for (int i = 0; i < (int)m; i++) {
    pos[b[i]] = i;
    bs.insert(make_pair(b[i], i));
  }
  for (int i = 0; i < (int)m; i++) right_b[i] = pos[b[i]];
  pos.clear();
  for (int i = 0; i < (int)n; i++) pos[a[i]] = i;
  for (int i = 0; i < (int)n; i++) right_a[i] = pos[a[i]];
  int ans = 0;
  int lim = s / e;
  for (int i = 0; i < (int)lim + 1; i++) dp[i] = inf;
  dp[0] = -1;
  for (int i = 0; i < (int)n; i++)
    for (int j = lim; j >= 0; j--)
      if (dp[j] < inf) {
        set<pair<int, int> >::iterator it =
            bs.lower_bound(make_pair(a[i], dp[j] + 1));
        if (it != bs.end() && it->first == a[i]) {
          dp[j + 1] = min(dp[j + 1], it->second);
          int cost = i + it->second + 2;
          if (cost + (j + 1) * e <= s) ans = max(ans, j + 1);
        }
      }
  cout << ans << endl;
  return 0;
}
