#include <bits/stdc++.h>
using namespace std;
const long long maxN = 1e5 + 7, MOD = 1e9 + 7, INF = 1e9 + 7, N = 3e2 + 7;
int dp[maxN][3], mini, n, m, s, e, a[maxN], b[maxN], ans, help;
vector<int> v[maxN];
int main() {
  cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= m; i++) cin >> b[i], v[b[i]].push_back(i);
  for (int i = 1; i <= n; i++) {
    if (v[a[i]].size()) {
      dp[i][1] = v[a[i]][0];
      help = e + dp[i][1] + i;
      if (help <= s) ans = max(ans, 1);
    } else
      dp[i][1] = INF;
  }
  for (int j = 2; j <= 300; j++) {
    mini = INF;
    for (int i = 1; i <= n; i++) {
      if (mini == INF || !v[a[i]].size() ||
          mini + 1 > v[a[i]][v[a[i]].size() - 1])
        dp[i][j & 1] = INF;
      else {
        help =
            upper_bound(v[a[i]].begin(), v[a[i]].end(), mini) - v[a[i]].begin();
        dp[i][j & 1] = v[a[i]][help];
        help = (j * e) + dp[i][j & 1] + i;
        if (help <= s) ans = max(ans, j);
      }
      mini = min(mini, dp[i][(j - 1) & 1]);
    }
  }
  return cout << ans << "\n", 0;
}
