#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const double EPS = 1e-8;
const double PI = acos(-1);
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &t) {
  os << "[";
  for (__typeof((t).begin()) it = (t).begin(); it != (t).end(); ++it) {
    if (it != t.begin()) os << ",";
    os << *it;
  }
  os << "]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &t) {
  os << "{";
  for (__typeof((t).begin()) it = (t).begin(); it != (t).end(); ++it) {
    if (it != t.begin()) os << ",";
    os << *it;
  }
  os << "}";
  return os;
}
template <class S, class T>
ostream &operator<<(ostream &os, const pair<S, T> &t) {
  return os << "(" << t.first << "," << t.second << ")";
}
template <int N, class Tuple>
void out(ostream &, const Tuple &) {}
template <int N, class Tuple, class, class... Ts>
void out(ostream &os, const Tuple &t) {
  if (N) os << ",";
  os << get<N>(t);
  out<N + 1, Tuple, Ts...>(os, t);
}
template <class... Ts>
ostream &operator<<(ostream &os, const tuple<Ts...> &t) {
  os << "(";
  out<0, tuple<Ts...>, Ts...>(os, t);
  os << ")";
  return os;
}
template <class T>
void output(T *a, int n) {
  for (int i = 0; i < (int)(n); ++i) {
    if (i) cout << ",";
    cout << a[i];
  }
  cout << endl;
}
template <class T>
void output(T *a, int n, int m) {
  for (int i = 0; i < (int)(n); ++i) output(a[i], m);
}
int dp[100001][301];
int a[100001];
int b[100001];
vector<int> g[100001];
int main() {
  int n, m, s, e;
  while (cin >> n >> m >> s >> e) {
    for (int i = 0; i < (int)(n); ++i) scanf("%d", a + i);
    for (int i = 0; i < (int)(m); ++i) scanf("%d", b + i);
    for (int i = 0; i < (int)(100001); ++i) g[i].clear();
    for (int i = 0; i < (int)(m); ++i) g[b[i]].push_back(i);
    int t = s / e;
    for (int i = 0; i < (int)(n + 1); ++i)
      for (int j = 0; j < (int)(t + 1); ++j) dp[i][j] = INF;
    dp[0][0] = -1;
    int ans = 0;
    for (int i = 0; i < (int)(n); ++i) {
      for (int j = 0; j < (int)(t); ++j) {
        chmin(dp[i + 1][j], dp[i][j]);
        auto it = upper_bound((g[a[i]]).begin(), (g[a[i]]).end(), dp[i][j]);
        if (it == g[a[i]].end()) continue;
        chmin(dp[i + 1][j + 1], *it);
      }
    }
    for (int i = 0; i < (int)(n + 1); ++i)
      for (int j = 0; j < (int)(t + 1); ++j) {
        if (e * j + i + dp[i][j] + 1 <= s) {
          chmax(ans, j);
        }
      }
    cout << ans << endl;
  }
}
