#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &item) {
  out << '(' << item.first << ", " << item.second << ')';
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  for (const auto &item : v) out << item << ' ';
  return out;
}
const int N = 100010;
const int ANS = 310;
int a[N], b[N], dp[N][ANS];
vector<int> posb[N];
void upd(int &x, int y) {
  if (x == -1)
    x = y;
  else
    x = min(x, y);
}
int getNext(int p, int x) {
  auto it = upper_bound(posb[x].begin(), posb[x].end(), p);
  if (it == posb[x].end()) return -1;
  return *it;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m, s, e;
  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], posb[b[i]].push_back(i);
  memset(dp, -1, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < ANS; ++j) {
      if (dp[i][j] < 0) continue;
      upd(dp[i + 1][j], dp[i][j]);
      int p = getNext(dp[i][j], a[i + 1]);
      if (p > 0) upd(dp[i + 1][j + 1], p);
    }
  int ans = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j < ANS; ++j)
      if (dp[i][j] >= 0 && j * e + i + dp[i][j] <= s) ans = max(ans, j);
  cout << ans << '\n';
  return 0;
}
