#include <bits/stdc++.h>
using namespace std;
vector<int> bin[100001];
int d[100001][301];
int v[100001][301];
int a[100001];
int b[100001];
int s, n;
int src(int k, int f) {
  if (bin[k].size() == 0) return -1;
  int l = -1;
  int r = bin[k].size() - 1;
  int m = (l + r) / 2;
  while (l < r - 1) {
    if (bin[k][m] >= f) {
      r = m;
    } else {
      l = m;
    }
    m = (l + r + 1) / 2;
  }
  if (bin[k][r] < f) return -1;
  return r;
}
int main() {
  int m, e;
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
    bin[b[i]].push_back(i);
  }
  d[0][0] = -1;
  for (int i = 0; i < n; i++) {
    for (int k = 0; k * e <= s; k++) {
      if (d[i][k] != 0) {
        if (d[i][k] == -1) d[i][k] = 0;
        if (d[i + 1][k + 1] == 0) {
          d[i + 1][k + 1] = src(a[i + 1], d[i][k] + 1);
          if (d[i + 1][k + 1] == -1)
            d[i + 1][k + 1] = 0;
          else
            d[i + 1][k + 1] = bin[a[i + 1]][d[i + 1][k + 1]];
          v[i + 1][k + 1] = i + 1;
        } else {
          int l = src(a[i + 1], d[i][k] + 1);
          if (d[i + 1][k + 1] > l) {
            d[i + 1][k + 1] = l;
            v[i + 1][k + 1] = i + 1;
          }
        }
        if (d[i + 1][k + 1] + v[i + 1][k + 1] + (k + 1) * e > s)
          d[i + 1][k + 1] = 0;
        if (d[i + 1][k] == 0) {
          if (d[i][k] != 0) {
            d[i + 1][k] = d[i][k];
          } else {
            d[i + 1][k] = -1;
          }
          v[i + 1][k] = v[i][k];
        } else {
          if (d[i + 1][k] > d[i][k]) {
            d[i + 1][k] = d[i][k];
            v[i + 1][k] = v[i][k];
          }
        }
        if (d[i + 1][k] + v[i + 1][k] + k * e > s) d[i + 1][k] = 0;
      }
    }
  }
  for (int i = s / e; i > 0; i--) {
    if (d[n][i] > 0) {
      cout << i;
      return 0;
    }
  }
  cout << 0;
  return 0;
}
