#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
int ans;
int n, m, s, e, a[N], b[N], p[N];
int dp[320][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  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];
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j <= n; j++) dp[i][j] = 1e9;
  }
  for (int i = 1; i <= 300; i++) {
    int l = m + 1;
    for (int j = 1; j <= 100000; j++) p[j] = 1e9;
    for (int j = max(i - 1, 1); j <= n; j++) {
      int r = l;
      l = min(dp[i - 1][j - 1] + 1, l);
      for (int k = r - 1; k >= l; k--) p[b[k]] = k;
      dp[i][j] = p[a[j]];
      if ((s - j - dp[i][j]) >= e * i) ans = i;
    }
  }
  cout << ans;
}
