#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
const int inf = (int)1e9;
int a[maxn], b[maxn], dp[333];
int size[maxn];
vector<int> pos[maxn];
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &b[i]);
    pos[b[i]].push_back(i);
  }
  for (int i = 0; i < maxn; i++) {
    size[i] = (int)(pos[i]).size();
  }
  for (int i = 1; i <= 300; i++) {
    dp[i] = inf;
  }
  int res = 0;
  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 300; j >= 1; j--) {
      int p = lower_bound((pos[a[i]]).begin(), (pos[a[i]]).end(), dp[j - 1]) -
              pos[a[i]].begin();
      if (p == size[a[i]]) continue;
      p = pos[a[i]][p];
      dp[j] = min(dp[j], p + 1);
      if (i + 1 + dp[j] + j * e <= s) {
        res = max(res, j);
      }
    }
  }
  cout << res << endl;
  return 0;
}
