#include <bits/stdc++.h>
using namespace std;
unsigned int dp[100010][400];
vector<int> nima[100010];
int a[100010], b[100010];
int n, m, s, e;
int main() {
  while (cin >> n >> m >> s >> e) {
    memset(dp, -1, sizeof(dp));
    for (int i = 0; i < n; ++i) {
      scanf("%d", &a[i]);
    }
    for (int i = 0; i < m; ++i) {
      scanf("%d", &b[i]);
      nima[b[i]].push_back(i + 1);
    }
    int ans = 0;
    int cnt = s / e;
    for (int i = 0; i < n; ++i) {
      dp[i][0] = 0;
      if (nima[a[i]].size())
        dp[i][1] = nima[a[i]][0];
      else
        dp[i][1] = -1;
      if (i == 0) continue;
      for (int j = 1; j <= cnt; ++j) {
        unsigned int now = -1;
        int w = a[i];
        int last = dp[i - 1][j - 1];
        now =
            upper_bound(nima[w].begin(), nima[w].end(), last) - nima[w].begin();
        if (now == nima[w].size() || dp[i - 1][j - 1] == -1) {
          now = -1;
        } else {
          now = nima[w][now];
        }
        dp[i][j] = min(dp[i - 1][j], now);
      }
    }
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < cnt + 1; ++j) {
        if (dp[i][j] != -1) {
          if (i + dp[i][j] + 1 + j * e <= s) ans = max(ans, j);
        }
      }
    cout << ans << endl;
    return 0;
  }
}
