#include <bits/stdc++.h>
using namespace std;
int n, m, s, e, ans;
int a[100010], b[100010], dp[305][100010];
vector<int> ed[100010];
int main() {
  int i, j, k;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (j = 1; j <= m; j++) {
    scanf("%d", &b[j]);
    ed[b[j]].push_back(j);
  }
  for (i = 0; i < 100010; i++) ed[i].push_back((1U << 31) - 1);
  memset(dp, -1, sizeof(dp));
  memset(dp[0], 0, sizeof(dp[0]));
  for (i = 1; i <= s / e; i++) {
    for (j = 1; j <= n; j++) {
      if (dp[i - 1][j - 1] != -1) {
        dp[i][j] = dp[i][j - 1];
        k = lower_bound(ed[a[j]].begin(), ed[a[j]].end(),
                        dp[i - 1][j - 1] + 1) -
            ed[a[j]].begin();
        k = ed[a[j]][k];
        if (k == (1U << 31) - 1) continue;
        if (dp[i][j] == -1 || dp[i][j] > k) dp[i][j] = k;
        if (dp[i][j] + j + i * e <= s) ans = max(ans, i);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
