#include <bits/stdc++.h>
using namespace std;
vector<int> ming[100005];
vector<int>::iterator it;
int dp[305][100005];
int a[100005];
int b[100005];
int main() {
  int n, m, s, e;
  while (scanf("%d%d%d%d", &n, &m, &s, &e) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= 100000; i++) ming[i].clear();
    for (int i = 1; i <= m; i++) {
      scanf("%d", &b[i]);
      ming[b[i]].push_back(i);
    }
    for (int i = 1; i <= 300; i++)
      for (int j = 0; j <= 100000; j++) dp[i][j] = 999999999;
    for (int j = 0; j <= 100000; j++) dp[0][j] = 0;
    int v = s / e;
    for (int i = 1; i <= v; i++) {
      for (int j = 1; j <= n; j++) {
        dp[i][j] = dp[i][j - 1];
        it =
            upper_bound(ming[a[j]].begin(), ming[a[j]].end(), dp[i - 1][j - 1]);
        if (it == ming[a[j]].end()) {
          continue;
        }
        dp[i][j] = min(*it, dp[i][j]);
      }
    }
    int ans = 0;
    for (int i = 1; i <= v; i++)
      for (int j = i; j <= n; j++) {
        if (dp[i][j] < 999999999 && (j + dp[i][j]) + i * e <= s) {
          ans = i;
        }
      }
    printf("%d\n", ans);
  }
}
