#include <bits/stdc++.h>
using namespace std;
inline void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T &$val, const Args &...args) {
  string $name;
  *iss >> $name;
  if ($name.back() == ',') $name.pop_back();
  cout << $name << " = " << $val << "; ", err(iss, args...);
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
int n, m, K, T, Q, cn;
int s, e, a[100005], b[100005], dp[5][305];
vector<int> posb[100005];
int main() {
  cin.tie(NULL);
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]), posb[b[i]].push_back(i);
  }
  for (int i = 0; i < 100005; i++) {
    posb[i].push_back(m + 1);
  }
  int mx = 0;
  for (int i = 1; i < 305; i++) {
    dp[0][i] = m + 1;
  }
  for (int i = 1; i <= n; i++) {
    int at = i & 1, prv = at ^ 1;
    for (int j = 1; j < 305; j++) {
      if (dp[prv][j - 1] <= m)
        dp[at][j] = min(
            dp[prv][j],
            *upper_bound(posb[a[i]].begin(), posb[a[i]].end(), dp[prv][j - 1]));
      else
        dp[at][j] = dp[prv][j];
      if (dp[at][j] <= m and i + dp[at][j] + j * ll(e) <= s) mx = max(mx, j);
    }
  }
  printf("%d\n", mx);
  return 0;
}
