#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
long long mod = 1e9 + 7;
long long powm(long long a, long long b, long long mod) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
bool sortinrev(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first > b.first);
}
int n, m, s, e;
int a[100001], b[100001];
int dp[100001][305], d[302];
vector<int> fre2[100005];
void solve() {
  cin >> n >> m >> s >> e;
  for (int i = 0; i < (n); i++) cin >> a[i + 1];
  for (int i = 0; i < (m); i++)
    cin >> b[i + 1], fre2[b[i + 1]].push_back(i + 1);
  for (int i = 0; i < (100001); i++) fre2[i].push_back(1e6);
  memset(dp, 0, sizeof(dp));
  memset(d, 0, sizeof(d));
  int ans = 0;
  dp[0][0] = 0;
  int ma = s / e + 1;
  for (int i = (1); i < (1 + n); i++) {
    int now = a[i];
    for (int j = (ma)-1; j >= 0; j--) {
      if (d[j] != 0 || j == 0) {
        int ind = (lower_bound(fre2[now].begin(), fre2[now].end(), d[j] + 1) -
                   fre2[now].begin());
        if (ind != fre2[now].size()) {
          ind = fre2[now][ind];
          if (d[j + 1] == 0 || d[j + 1] > ind) d[j + 1] = ind;
          if (e * (j + 1) + i + ind <= s) ans = max(ans, j + 1);
        }
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  int tc = 1;
  while (tc--) {
    solve();
  }
  return 0;
}
