#include <bits/stdc++.h>
using namespace std;
int dp[320][110000];
int a[110000], b[110000];
const int inf = 10000000;
int n, m, s, e;
vector<int> g[110000];
int main() {
  while (~scanf("%d%d%d%d", &n, &m, &s, &e)) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 0; i <= 100000; i++) g[i].clear();
    for (int j = 1; j <= m; j++) {
      scanf("%d", &b[j]);
      g[b[j]].push_back(j);
    }
    for (int i = 0; i <= 100000; i++) g[i].push_back(inf);
    memset(dp, 0x3f, sizeof dp);
    memset(dp[0], 0, sizeof dp[0]);
    for (int i = 1; i < 301; i++) {
      for (int j = i; j <= n; j++) {
        if (dp[i - 1][j - 1] < inf) {
          dp[i][j] = dp[i][j - 1];
          int ps = *lower_bound(g[a[j]].begin(), g[a[j]].end(),
                                dp[i - 1][j - 1] + 1);
          dp[i][j] = min(dp[i][j], ps);
        }
      }
    }
    int ans = 0;
    for (int i = 1; i < 301; i++)
      for (int j = i; j <= n; j++)
        if (dp[i][j] < inf && (j + dp[i][j]) + i * e <= s) {
          ans = max(ans, i);
        }
    printf("%d\n", ans);
  }
  return 0;
}
