#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  int const MAX_NUMBER = 1e5 + 1;
  vector<int> a(n), b(m);
  vector<vector<int> > c(MAX_NUMBER);
  for (int i = (0); i < ((n)); ++i) cin >> a[i];
  for (int i = (0); i < ((m)); ++i) {
    cin >> b[i];
    c[b[i]].push_back(i);
  }
  int const xMax = s / e;
  int bestX = 0;
  vector<int> dp(n, -1);
  for (int x = (1); x < (xMax + 1); ++x) {
    if (x == 1) {
      for (int i = (0); i < ((n)); ++i) {
        if (c[a[i]].empty())
          dp[i] = -1;
        else {
          dp[i] = c[a[i]].front();
          int const cost = i + dp[i] + 2 + x * e;
          if (cost <= s) {
            bestX = max(bestX, x);
          }
        }
      }
    } else {
      int left = -1;
      for (int i = (0); i < ((n)); ++i) {
        if (dp[i] == -1) continue;
        if (left == -1) {
          left = dp[i];
          dp[i] = -1;
          continue;
        }
        auto it = upper_bound(c[a[i]].begin(), c[a[i]].end(), left);
        if (left > dp[i]) left = dp[i];
        if (it == c[a[i]].end()) {
          dp[i] = -1;
          continue;
        }
        int const cost = i + *it + 2 + x * e;
        if (cost <= s) {
          bestX = max(bestX, x);
        }
        dp[i] = *it;
      }
    }
  }
  cout << bestX << endl;
  return 0;
}
