#include <bits/stdc++.h>
using namespace std;
vector<int> idb[100002];
int dp[301];
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) {
    int b;
    scanf("%d", &b);
    idb[b].push_back(i);
  }
  int ans = 0;
  memset(dp, 127, sizeof dp);
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 300; j >= 1; j--) {
      int pos2array = dp[j - 1];
      int nextPos = lower_bound(idb[a[i]].begin(), idb[a[i]].end(), pos2array) -
                    idb[a[i]].begin();
      if (nextPos == idb[a[i]].size()) continue;
      int abspos2ar = idb[a[i]][nextPos];
      dp[j] = min(dp[j], abspos2ar + 1);
      if (i + 1 + dp[j] + j * e <= s) ans = max(ans, j);
    }
  }
  cout << ans;
  return 0;
}
