#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
static inline int Rint() {
  struct X {
    int dig[256];
    X() {
      for (int i = '0'; i <= '9'; ++i) dig[i] = 1;
      dig['-'] = 1;
    }
  };
  static X fuck;
  int s = 1, v = 0, c;
  for (; !fuck.dig[c = getchar()];)
    ;
  if (c == '-')
    s = 0;
  else if (fuck.dig[c])
    v = c ^ 48;
  for (; fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48))
    ;
  return s ? v : -v;
}
template <typename T>
static inline void cmax(T& a, const T& b) {
  if (b > a) a = b;
}
template <typename T>
static inline void cmin(T& a, const T& b) {
  if (b < a) a = b;
}
const int maxn = 100005;
int A[maxn], B[maxn];
int dp[305];
vector<int> pos[maxn];
int main() {
  int n = Rint(), m = Rint(), s = Rint(), e = Rint();
  for (int i = (1); i < (n + 1); ++i) A[i] = Rint();
  for (int i = (1); i < (m + 1); ++i) B[i] = Rint();
  for (int i = (1); i < (m + 1); ++i) pos[B[i]].push_back(i);
  memset(dp, -1, sizeof dp);
  dp[0] = 0;
  int best = 0;
  int limit = max(s / e, 10);
  for (int i = 1; i <= n; ++i) {
    for (int j = min(i, limit); j >= 1; --j) {
      if (dp[j - 1] == -1) continue;
      vector<int>& vec = pos[A[i]];
      const int size = vec.size();
      int l = 0, r = size - 1;
      while (l <= r) {
        const int mid = l + r >> 1;
        if (vec[mid] > dp[j - 1])
          r = mid - 1;
        else
          l = mid + 1;
      }
      if (l != size) {
        if (dp[j] == -1 || dp[j] > vec[l]) dp[j] = vec[l];
        if (dp[j] != -1) {
          long long energy = (long long)j * e + i + dp[j];
          if (energy <= s) {
            if (j > best) best = j;
          }
        }
      }
    }
  }
  printf("%d\n", best);
  return 0;
}
