#include <bits/stdc++.h>
using namespace std;
int dp[110000][330];
vector<int> vec[110000];
int a[110000];
int b[110000];
int sea(int x, int y) {
  int l = 0;
  int r = vec[y].size();
  int mid = (l + r) / 2;
  while (l < r) {
    if (vec[y][mid] <= x)
      l = mid + 1;
    else
      r = mid;
    mid = (l + r) / 2;
  }
  if (mid == vec[y].size())
    return 99999999;
  else
    return vec[y][mid];
}
int main() {
  int n, m, s, e;
  int k;
  int i, j;
  while (~scanf("%d%d%d%d", &n, &m, &s, &e)) {
    k = s / e;
    for (i = 0; i <= n; i++) {
      vec[i].clear();
      for (j = 0; j <= k; j++) dp[i][j] = 99999999;
    }
    for (i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (i = 1; i <= m; i++) scanf("%d", &b[i]);
    for (i = 1; i <= m; i++) {
      vec[b[i]].push_back(i);
    }
    int ans = 0;
    dp[0][0] = 0;
    for (i = 1; i <= n; i++) {
      dp[i][0] = 0;
      for (j = 1; j <= k && j <= i; j++) {
        int x = dp[i - 1][j - 1];
        int ps = sea(x, a[i]);
        dp[i][j] = (dp[i - 1][j]) > (ps) ? (ps) : (dp[i - 1][j]);
        if (j > ans) {
          if (i + dp[i][j] + j * e <= s) {
            ans = j;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
