#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
vector<int> l[100010];
int n, m, s, e;
int dp[100010][310];
int main() {
  memset(dp, 0x3f3f3f, sizeof(dp));
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    l[b[i]].push_back(i);
  }
  int tot = s / e;
  int ans = 0;
  dp[0][0] = 0;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = 0;
    for (int j = 1; j <= tot; j++) {
      dp[i][j] = dp[i - 1][j];
      int aa = upper_bound(l[a[i]].begin(), l[a[i]].end(), dp[i - 1][j - 1]) -
               l[a[i]].begin();
      if (aa < l[a[i]].size()) {
        dp[i][j] = min(dp[i][j], l[a[i]][aa]);
      }
      if (j > ans && j * e + i + dp[i][j] <= s) {
        ans = j;
      }
    }
  }
  printf("%d", ans);
}
