#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int maximize(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline int minimize(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 100005, INF = 0x3f3f3f3f;
int dp[N][303], n, m, s, e, a[N], b[N], nxt[N];
int main() {
  cin >> 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);
  int up = s / e;
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int j = 1; j <= up; ++j) {
    memset(nxt, -1, sizeof(nxt));
    if (~dp[0][j - 1])
      for (int k = m; k > dp[0][j - 1]; --k) nxt[b[k]] = k;
    int x = m;
    for (int i = 1; i <= n; ++i) {
      dp[i][j] = nxt[a[i]];
      if (dp[i][j - 1] == -1) continue;
      for (int k = x; k > dp[i][j - 1]; --k) {
        nxt[b[k]] = k;
      }
      minimize(x, dp[i][j - 1]);
    }
  }
  for (int j = up; j; --j) {
    for (int i = 1; i <= n; ++i) {
      if (~dp[i][j] && j * e + i + dp[i][j] <= s) {
        cout << j << endl;
        exit(0);
      }
    }
  }
  cout << 0 << endl;
  return 0;
}
