#include <bits/stdc++.h>
using namespace std;
long long int arr[100005], brr[100005], dp[305][100005];
vector<long long int> positions[100005];
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  long long int i, j, k, l, n, m, s, e, ans = 0, lo, mid, hi, ind, x, y,
                                        max_ops;
  cin >> n >> m >> s >> e;
  max_ops = s / e;
  max_ops = min(max_ops, min(n, m));
  for (i = 1; i <= n; i++) cin >> arr[i];
  for (i = 1; i <= m; i++) {
    cin >> brr[i];
    positions[brr[i]].push_back(i);
  }
  for (i = 0; i <= max_ops; i++) {
    for (j = 0; j <= n; j++) dp[i][j] = 100000000000000;
  }
  if (positions[arr[1]].size())
    dp[1][1] = positions[arr[1]][0];
  else
    dp[1][1] = 100000000000000;
  for (i = 2; i <= n; i++) {
    dp[1][i] = dp[1][i - 1];
    if (positions[arr[i]].size())
      dp[1][i] = min(dp[1][i], positions[arr[i]][0]);
  }
  for (i = 2; i <= max_ops; i++) {
    for (j = i; j <= n; j++) {
      dp[i][j] = dp[i][j - 1];
      ind = dp[i - 1][j - 1];
      if (ind == 100000000000000) continue;
      if (!positions[arr[j]].size()) continue;
      lo = -1;
      hi = positions[arr[j]].size() - 1;
      if (positions[arr[j]][hi] <= ind) continue;
      while (hi - lo > 1) {
        mid = (lo + hi) / 2;
        if (positions[arr[j]][mid] > ind)
          hi = mid;
        else
          lo = mid;
      }
      dp[i][j] = min(dp[i][j], positions[arr[j]][hi]);
    }
  }
  for (i = 1; i <= max_ops; i++) {
    for (j = 1; j <= n; j++) {
      if (dp[i][j] == 100000000000000) continue;
      x = dp[i][j] + j + i * e;
      if (x <= s) ans = max(ans, i);
    }
  }
  cout << ans;
  return 0;
}
