#include <bits/stdc++.h>
using namespace std;
int q[100100];
int p[100100];
vector<int> Q[100100];
int dp[2][100100];
int main() {
  int T;
  int n, m, s, e;
  while (~scanf("%d%d%d%d", &n, &m, &s, &e)) {
    for (int i = 1; i <= n; i++) scanf("%d", &q[i]);
    for (int j = 1; j <= m; j++) {
      scanf("%d", &p[j]);
      Q[p[j]].push_back(j);
    }
    int res = 0;
    int t = s / e;
    int cnt = 1;
    dp[0][0] = 0;
    for (int i = 1; i <= t; i++) {
      for (int j = i; j <= n; j++) {
        dp[cnt ^ 1][j] = min(dp[cnt ^ 1][j], dp[cnt ^ 1][j - 1]);
        int ans =
            upper_bound(Q[q[j]].begin(), Q[q[j]].end(), dp[cnt ^ 1][j - 1]) -
            Q[q[j]].begin();
        if (ans == Q[q[j]].size())
          dp[cnt][j] = s + 1;
        else {
          dp[cnt][j] = Q[q[j]][ans];
          if (dp[cnt][j] + j + i * e <= s) res = max(res, i);
        }
      }
      cnt ^= 1;
    }
    printf("%d\n", res);
  }
  return 0;
}
