#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int M = 310;
int n, m, s, e0, E;
pair<int, int> dp[N][M];
int a[N];
vector<int> elAtB[N];
inline int findj(int j0, int val) {
  if (j0 >= m) return -1;
  vector<int> &v = elAtB[val];
  if (v.size() == 0) return -1;
  vector<int>::iterator it = lower_bound(v.begin(), v.end(), j0);
  if (it == v.end())
    return -1;
  else
    return *it;
}
int main() {
  cin >> n >> m >> s >> e0;
  E = s / e0;
  int ost = s - E * e0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int j = 0; j < m; j++) {
    int x;
    cin >> x;
    elAtB[x].push_back(j);
  }
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int e = 0; e <= E; e++) {
      dp[i][e] = make_pair(0, 0);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int e = 1; e <= E; e++) {
      int dol = dp[i][e].first;
      int j0 = dp[i][e].second;
      int dolnxt = dp[i + 1][e].first;
      if (dol > dolnxt) {
        dp[i + 1][e] = make_pair(dol, j0);
      }
      int j = findj(j0, a[i]);
      if (j == -1)
        continue;
      else {
      }
      dolnxt = dp[i + 1][e - 1].first;
      int jnxt = dp[i + 1][e - 1].second;
      if (((dol + 1 > dolnxt) || (dol + 1 == dolnxt && j < jnxt)) &&
          ((i + 1 + j + 1) <= (e - 1) * e0 + ost)) {
        dp[i + 1][e - 1] = make_pair(dol + 1, j + 1);
        ans = max(ans, dol + 1);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
