#include <bits/stdc++.h>
using namespace std;
int n, m, s, e, dp[305][100005];
int num1[100005], num2[100005];
vector<int> save[100005];
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) scanf("%d", &num1[i]);
  for (int i = 0; i <= 100000; i++) save[i].clear();
  for (int i = 1; i <= m; i++) {
    scanf("%d", &num2[i]);
    save[num2[i]].push_back(i);
  }
  for (int i = 0; i <= 100000; i++) save[i].push_back(1000000000);
  for (int i = 0; i <= 300; i++) {
    for (int j = 0; j <= n; j++) dp[i][j] = 1000000000;
  }
  for (int i = 0; i <= n; i++) dp[0][i] = 0;
  for (int i = 1; i <= 300; i++) {
    for (int j = 1; j <= n; j++) {
      if (dp[i - 1][j - 1] >= 1000000000) continue;
      dp[i][j] = dp[i][j - 1];
      int tmp = *lower_bound(save[num1[j]].begin(), save[num1[j]].end(),
                             dp[i - 1][j - 1] + 1);
      dp[i][j] = min(dp[i][j], tmp);
    }
  }
  int ans = 0;
  for (int i = 0; i <= 300; i++) {
    for (int j = 1; j <= n; j++) {
      if (j + dp[i][j] + i * e <= s) ans = max(ans, i);
    }
  }
  printf("%d\n", ans);
  return 0;
}
