#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int maxw = 1e5;
int n, m, s, e, a[N], b[N];
vector<int> pos[maxw + 10];
int dp[N][302], ans;
void upd(int& a, int b) {
  if (a == -1 || b < a) a = b;
}
int main() {
  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);
  for (int i = 1; i <= m; i++) pos[b[i]].push_back(i);
  for (int i = 1; i <= maxw; i++) pos[i].push_back(m + 1);
  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= s / e; j++)
      if (dp[i][j] != -1) {
        if (i < n) {
          upd(dp[i + 1][j], dp[i][j]);
          int nx = *upper_bound(pos[a[i + 1]].begin(), pos[a[i + 1]].end(),
                                dp[i][j]);
          if (nx <= m) upd(dp[i + 1][j + 1], nx);
        }
        if (i + dp[i][j] + j * e <= s) ans = max(ans, j);
      }
  printf("%d\n", ans);
}
