#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, K = 310, C = 26, INF = 1e9;
int dp[N][K], nex[N][C];
int a[N], b[N], res = 0;
vector<int> ind[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m, s, e, limit;
  cin >> n >> m >> s >> e;
  limit = s / e;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    ind[b[i]].push_back(i);
  }
  memset(dp, -1, sizeof dp);
  for (int j = 1; j <= limit; j++) dp[0][j] = INF;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= limit; j++) {
      dp[i][j] = dp[i - 1][j];
      int id = upper_bound(ind[a[i - 1]].begin(), ind[a[i - 1]].end(),
                           dp[i - 1][j - 1]) -
               ind[a[i - 1]].begin();
      if (id < (int)ind[a[i - 1]].size())
        dp[i][j] = min(dp[i][j], ind[a[i - 1]][id]);
      if (s - e * j - i - dp[i][j] - 1 >= 0) res = max(res, j);
    }
  }
  cout << res << endl;
}
