#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
const int N = 100000 + 200;
int dp[305][N] = {0}, p[N], a[N], b[N];
vector<int> pos[N];
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = int(1); i <= (int)n; i++) cin >> a[i];
  for (int i = int(1); i <= (int)m; i++) cin >> b[i];
  for (int i = 1; i <= m; ++i) pos[b[i]].push_back(i);
  int mxcomm = s / e;
  for (int i = 1; i <= 100000; ++i) p[i] = pos[i].size() - 1;
  int it, f, mid;
  for (int i = 1; i <= mxcomm; ++i) {
    int mnpossofar = 1e7;
    if (i == 1) mnpossofar = 0;
    for (int j = 1; j <= n; ++j) {
      if (p[a[j]] == -1) {
        dp[i][j] = 1e7;
      } else if (mnpossofar >= pos[a[j]][p[a[j]]]) {
        dp[i][j] = 1e7;
      } else {
        it = 0, f = p[a[j]];
        while (it != f) {
          mid = (it + f) / 2;
          if (pos[a[j]][mid] > mnpossofar)
            f = mid;
          else
            it = mid + 1;
        }
        dp[i][j] = pos[a[j]][f];
      }
      mnpossofar = min(mnpossofar, dp[i - 1][j]);
    }
  }
  int answer = 0, E;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= mxcomm; ++j) {
      if (dp[j][i] <= m) {
        int ele = i + dp[j][i];
        E = ele + j * e;
        if (s >= E) answer = max(answer, j);
      }
    }
  }
  cout << answer << endl;
  return 0;
}
