#include <bits/stdc++.h>
using namespace std;
int dp[100007][305];
int a[100007], b[100007];
std::vector<int> v[100007];
int main() {
  int n, m, s, e;
  int i, j;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
    v[b[i]].push_back(i);
  }
  int S = s / e;
  for (i = 1; i <= n; i++) {
    dp[i][0] = -1;
    for (j = 1; j <= S; j++) dp[i][j] = 1000000007;
  }
  for (i = 1; i <= m; i++) {
    if (b[i] == a[1]) {
      dp[1][1] = i;
      break;
    }
  }
  vector<int>::iterator it;
  for (i = 2; i <= n; i++) {
    for (j = 0; j <= S; j++) {
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      it = upper_bound(v[a[i]].begin(), v[a[i]].end(), dp[i - 1][j]);
      if (it != v[a[i]].end()) dp[i][j + 1] = min(dp[i][j + 1], *it);
    }
  }
  int res = -1000000007;
  for (i = 1; i <= n; i++) {
    for (j = 0; j <= S; j++) {
      if (i + dp[i][j] + j * e <= s) res = max(res, j);
    }
  }
  printf("%d\n", res);
  return 0;
}
