#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1e5 + 5;
const int ANS = 299;
int n, m, s, e, a[N], b[N], bef[N], cur[N], ans;
vector<int> va[N], vb[N];
int main() {
  ios ::sync_with_stdio(0);
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    va[a[i]].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    vb[b[i]].push_back(i);
  }
  int next;
  for (int i = 1; i <= ANS; i++) {
    cur[0] = inf;
    for (int j = 1; j <= n; j++) {
      next = upper_bound(vb[a[j]].begin(), vb[a[j]].end(), bef[j - 1]) -
             vb[a[j]].begin();
      if (next == vb[a[j]].size())
        cur[j] = cur[j - 1];
      else {
        cur[j] = min(cur[j - 1], vb[a[j]][next]);
        if (j + vb[a[j]][next] + e * i <= s) ans = max(ans, i);
      }
    }
    for (int i = 0; i <= n; i++) bef[i] = cur[i];
  }
  cout << ans << '\n';
  return 0;
}
