#include <bits/stdc++.h>
using namespace std;
int dp[333][111111];
int a[111111], b[111111];
vector<int> v[111111];
int bi_search(int s, int k);
int main() {
  int n, m, s, e, i, j;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    v[a[i]].clear();
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    v[b[i]].clear();
  }
  for (i = 1; i <= n; i++) {
    v[a[i]].push_back(i);
  }
  memset(dp[0], 0, sizeof(dp[0]));
  int ma = 0;
  for (i = 1; i <= (s / e + 1); i++) {
    for (j = i; j <= m; j++) {
      int s = bi_search(b[j], dp[i - 1][j - 1]);
      if (j == i)
        dp[i][j] = s;
      else
        dp[i][j] = min(dp[i][j - 1], s);
    }
    ma = i;
    if (dp[i][m] == 9999999) break;
  }
  int ans = 0;
  for (i = 1; i <= ma; i++) {
    for (j = i; j <= m; j++) {
      if (dp[i][j] < 9999999) {
        if (dp[i][j] + j + i * e <= s) {
          ans = i;
        }
      }
    }
  }
  printf("%d\n", ans);
}
int bi_search(int s, int k) {
  int high, low;
  high = v[s].size() - 1;
  low = 0;
  if (v[s].size() == 0) return 9999999;
  if (v[s][high] <= k) return 9999999;
  if (v[s][low] > k) return v[s][low];
  while (high - low > 1) {
    int mid = (high + low) >> 1;
    if (v[s][mid] > k)
      high = mid;
    else
      low = mid;
  }
  return v[s][high];
}
