#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int MOD = 1000000007;
int a[100010], b[100010];
int dp[100010][512];
vector<int> same[100010];
int main() {
  int n, m;
  int money, cost;
  scanf("%d%d%d%d", &n, &m, &money, &cost);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= m; i++) {
    same[b[i]].push_back(i);
  }
  memset(dp, 0x3f, sizeof(dp));
  for (int i = 0; i <= n; i++) dp[i][0] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 300; j++) {
      if (dp[i - 1][j] < 0x3f3f3f3f) dp[i][j] = dp[i - 1][j];
      if (same[a[i]].size() && dp[i - 1][j - 1] < 0x3f3f3f3f) {
        int k = upper_bound(same[a[i]].begin(), same[a[i]].end(),
                            dp[i - 1][j - 1]) -
                same[a[i]].begin();
        if (k < same[a[i]].size()) dp[i][j] = min(dp[i][j], same[a[i]][k]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 300; j++) {
      if (dp[i][j] >= 0x3f3f3f3f) continue;
      if (dp[i][j] + i + j * cost <= money) {
        ans = max(ans, j);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
