#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, s, e;
int a[maxn], b[maxn], dp[305];
vector<int> bv[maxn];
int main() {
  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]);
    bv[b[i]].push_back(i);
  }
  int ans = 0;
  int len = s / e;
  memset(dp, 0x3f3f3f3f, sizeof(dp));
  dp[0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = min(i, len); j >= 1; j--) {
      vector<int>::iterator small_num;
      small_num = upper_bound(bv[a[i]].begin(), bv[a[i]].end(), dp[j - 1]);
      if (small_num == bv[a[i]].end()) continue;
      dp[j] = min(dp[j], *small_num);
      if (i + dp[j] + j * e <= s) {
        ans = max(j, ans);
      }
    }
  }
  printf("%d\n", ans);
}
