#include <bits/stdc++.h>
using namespace std;
int GCD(int a, int b) {
  if (!a) return b;
  return GCD(b % a, a);
}
int dp[309][100009];
int main() {
  clock_t startTime = clock();
  ios_base::sync_with_stdio(false);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  vector<int> a;
  a.reserve(n);
  for (int i = (0); i < (int)(n); i++) {
    int p;
    cin >> p;
    a.push_back(p);
  }
  vector<int> b[100009];
  for (int i = (0); i < (int)(m); i++) {
    int p;
    cin >> p;
    b[p].push_back(i);
  }
  for (int i = (0); i < (int)(n); i++) {
    if (b[a[i]].size()) {
      dp[1][i] = b[a[i]][0];
    } else
      dp[1][i] = (1 << 29);
  }
  for (int j = (2); j < (int)(s / e + 1); j++) {
    int min_element_removed = (1 << 29);
    for (int i = (0); i < (int)(n); i++) {
      auto it =
          upper_bound(b[a[i]].begin(), b[a[i]].end(), min_element_removed);
      if (it == b[a[i]].end()) {
        dp[j][i] = (1 << 29);
      } else {
        dp[j][i] = *it;
      }
      min_element_removed = min(min_element_removed, dp[j - 1][i]);
    }
  }
  int ans = 0;
  for (int j = (1); j < (int)(s / e + 1); j++) {
    for (int i = (0); i < (int)(n); i++) {
      int cost = j * e + i + dp[j][i] + 2;
      if (cost <= s) ans = j;
    }
  }
  cout << ans << "\n";
  clock_t endTime = clock();
  cerr << "\nTime:" << double(endTime - startTime) / CLOCKS_PER_SEC
       << " seconds\n";
  return 0;
}
