#include <bits/stdc++.h>
using namespace std;
vector<int> pos[100003];
int n, m, s, e, tmp;
int dp[2][100003];
int arr[100003];
int bs(int val, int x) {
  int l = -1, r = pos[val].size();
  if (r == 0) return 1000000000;
  if (x >= pos[val][r - 1]) return 1000000000;
  while (r - l > 1) {
    if (pos[val][(r + l) / 2] > x) {
      r = (r + l) / 2;
    } else {
      l = (r + l) / 2;
    }
  }
  return pos[val][r];
}
int main() {
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) {
    cin >> tmp;
    pos[tmp].push_back(i);
  }
  for (int i = 1; i <= m; i++) {
    cin >> arr[i];
    dp[0][i] = 2332;
  }
  dp[0][0] = 0;
  dp[1][0] = 1000000000;
  int mn, sol = 0;
  for (int k = 1; k <= s / e; k++) {
    mn = dp[(k + 1) % 2][0];
    for (int i = 1; i <= m; i++) {
      dp[k % 2][i] = bs(arr[i], mn);
      mn = min(dp[(k + 1) % 2][i], mn);
      if (dp[k % 2][i] != 1000000000 && i + dp[k % 2][i] <= s - e * k) {
        sol = max(sol, k);
      }
    }
    for (int i = 0; i <= m; i++) {
      dp[(k + 1) % 2][i] = 1000000000;
    }
  }
  cout << sol << endl;
}
