#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
vector<int> G[maxn];
int dp[302][maxn];
int A[maxn];
int B[maxn];
int main() {
  int n, m, s, e;
  int i, j, k;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &B[i]);
    G[B[i]].push_back(i);
  }
  memset(dp, -1, sizeof dp);
  memset(dp[0], 0, sizeof dp[0]);
  int d = s / e;
  int ans = 0;
  for (i = 1; i <= d; i++) {
    for (j = i; j <= n; j++) {
      dp[i][j] = dp[i][j - 1];
      if (dp[i - 1][j - 1] != -1) {
        vector<int>::iterator it;
        it = lower_bound(G[A[j]].begin(), G[A[j]].end(), dp[i - 1][j - 1] + 1);
        if (it != G[A[j]].end()) {
          if (dp[i][j] == -1)
            dp[i][j] = (*it);
          else
            dp[i][j] = min(dp[i][j], (*it));
        }
      }
      if (dp[i][j] != -1 && i * e + j + dp[i][j] <= s) ans = max(ans, i);
    }
  }
  cout << ans << endl;
  return 0;
}
