#include <bits/stdc++.h>
using namespace std;
vector<int> b[100005];
int f[2][100005], a[100005];
int n, m, s, e, x, maxn;
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", &x);
    b[x].push_back(i);
  }
  for (int i = 0; i <= 1; i++)
    for (int j = 1; j <= n; j++) f[i][j] = m + 1;
  for (int i = 0; i <= n; i++) f[0][i] = 0;
  maxn = 0;
  for (int i = 1; i <= 305; i++) {
    for (int j = 0; j <= n; j++) f[i % 2][j] = m + 1;
    for (int j = 1; j <= n; j++) {
      int k = f[(i - 1) % 2][j - 1];
      f[i % 2][j] = f[i % 2][j - 1];
      vector<int>::iterator it = upper_bound(b[a[j]].begin(), b[a[j]].end(), k);
      if (it != b[a[j]].end()) {
        int pos = *it;
        if (f[i % 2][j] > pos) f[i % 2][j] = pos;
      } else
        continue;
      if (f[i % 2][j] <= m) {
        if (j + f[i % 2][j] + i * e <= s && maxn < i) maxn = i;
      }
    }
  }
  printf("%d\n", maxn);
}
