#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000, N = 100005;
int a[N], b[N], ans, n, pos, m, s, e, i, k, j, dp[N][301];
vector<int> f[N];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> s >> e;
  k = s / e;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= m; i++) {
    cin >> b[i];
    f[b[i]].push_back(i);
  }
  for (i = 1; i <= n + 1; i++)
    for (j = 1; j <= k; j++) dp[i][j] = inf;
  for (i = 1; i <= n; i++)
    for (j = 0; j < k; j++)
      if (dp[i][j] != inf) {
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
        pos = upper_bound(f[a[i]].begin(), f[a[i]].end(), dp[i][j]) -
              f[a[i]].begin();
        if (pos < f[a[i]].size())
          dp[i + 1][j + 1] = min(dp[i + 1][j + 1], f[a[i]][pos]);
      }
  for (j = k; j > 0; j--)
    for (i = 1; i <= n + 1; i++)
      if (j * e + i - 1 + dp[i][j] <= s) {
        cout << j;
        return 0;
      }
  cout << 0;
}
