#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 100 + 10;
int a[MAXN], b[MAXN];
int dp[MAXN][310];
vector<int> vec1[MAXN], vec[MAXN];
long long n, m, second, E;
bool ok(int k) {
  long long need = second;
  for (int i = k - 1; i < n; i++)
    if (dp[i][k] < m) need = min(need, (long long)(i + 1 + dp[i][k] + 1));
  need += k * E;
  if (need <= second) return true;
  return false;
}
int bs(int s, int e) {
  if (e - s <= 1) return s;
  int m = (s + e) / 2;
  return ok(m) ? bs(m, e) : bs(s, m);
}
int main() {
  cin >> n >> m >> second >> E;
  for (int i = 0; i < n; i++) cin >> a[i], vec1[a[i]].push_back(i);
  for (int i = 0; i < m; i++) cin >> b[i], vec[b[i]].push_back(i);
  for (int i = 0; i < MAXN; i++) vec[i].push_back(m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 301; j++) dp[i][j] = m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < min(min((int)m, i + 1), 300) + 1; j++) {
      if (j == 0)
        dp[i][j] = -1;
      else if (i == 0)
        dp[i][j] =
            vec[a[i]][lower_bound(vec[a[i]].begin(), vec[a[i]].end(), 0) -
                      vec[a[i]].begin()];
      else
        dp[i][j] =
            min(dp[i - 1][j],
                (dp[i - 1][j - 1] >= m)
                    ? (int)m
                    : vec[a[i]]
                         [(int)(lower_bound(vec[a[i]].begin(), vec[a[i]].end(),
                                            dp[i - 1][j - 1] + 1) -
                                vec[a[i]].begin())]);
    }
  cout << bs(0, min({(int)m, (int)n, 300}) + 1) << endl;
  return 0;
}
