#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int maxn = 1000 * 100 + 50;
int a[maxn], b[maxn], n, m, s, e, dp[maxn][300 + 20];
vector<int> v[maxn];
int main() {
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    v[b[i]].push_back(i);
  }
  for (int i = 0; i < maxn; i++) {
    for (int j = 0; j < 310; j++) {
      dp[i][j] = INF;
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    dp[i][0] = 0;
    for (int j = 1; j <= min(i + 1, 300); j++) {
      int help = 0;
      if (i > 0) {
        dp[i][j] = dp[i - 1][j];
        help = dp[i - 1][j - 1];
      } else {
        dp[i][j] = INF;
      }
      if (v[a[i]].size() == 0) {
        continue;
      }
      int hh =
          lower_bound(v[a[i]].begin(), v[a[i]].end(), help) - v[a[i]].begin();
      if (hh == v[a[i]].size()) {
        continue;
      }
      dp[i][j] = min(dp[i][j], v[a[i]][hh] + 1);
      if (j * e + (i + 1 + dp[i][j]) <= s) {
        ans = max(ans, j);
      }
    }
  }
  cout << ans;
}
