#include <bits/stdc++.h>
using std::endl;
using std::max;
using std::upper_bound;
using std::vector;
const int MAX_SEQ_SIZE = 100 * 1000;
const int MAX_NUM = 100 * 1000;
const int MAX_S = 300 * 1000;
const int MIN_E = 1000;
const int MAX_N = MAX_SEQ_SIZE;
const int MAX_M = MAX_SEQ_SIZE;
static int solve(const int nn, const int ss, const int ee, const int* arrA,
                 const vector<int>* num2bi) {
  static int dp[(MAX_S / MIN_E) + 2];
  const int act_num = (ss / ee);
  int bucks = 0;
  for (int a_ind = 1; a_ind <= nn; ++a_ind) {
    const vector<int>& bind = num2bi[arrA[a_ind]];
    const vector<int>::const_iterator n2bi_b = bind.begin();
    const vector<int>::const_iterator n2bi_e = bind.end();
    for (int action_index = act_num, profit = act_num + 1; profit > 0;
         --profit, --action_index) {
      const int dp_curr = dp[action_index];
      if (!dp_curr && action_index) continue;
      const vector<int>::const_iterator n2bi_it =
          upper_bound(n2bi_b, n2bi_e, dp_curr);
      if (n2bi_it == n2bi_e) continue;
      const int b_ind = *n2bi_it;
      if ((profit * ee) + a_ind + b_ind <= ss) bucks = max(bucks, profit);
      int& dp_prev = dp[profit];
      if (dp_prev == 0 || dp_prev > b_ind) dp_prev = b_ind;
    }
  }
  return bucks;
}
int main(void) {
  std::ios_base::sync_with_stdio(false);
  using std::cin;
  using std::cout;
  if (!cin.good()) return 1;
  int N, M, S, E;
  cin >> N >> M >> S >> E;
  static int arrA[MAX_N + 1];
  for (int i = 1; i <= N; i++) cin >> arrA[i];
  static vector<int> num2bi[MAX_NUM + 1];
  {
    int num;
    for (int i = 1; i <= M; i++) {
      cin >> num;
      num2bi[num].push_back(i);
    }
  }
  if (!cin.eof() && !cin.good()) return 2;
  const int ans = solve(N, S, E, arrA, num2bi);
  cout << ans << endl;
  return 0;
}
