#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
vector<int> A, B;
vector<vector<int> > Pos;
vector<vector<int> > Save;
int Next(const vector<int> &P, int ind) {
  int l = 0, r = int(P.size()) - 1;
  while (l < r) {
    int m = (l + r) / 2;
    if (P[m] < ind) l = m + 1;
    if (P[m] > ind) r = m;
    if (P[m] == ind) return ind;
  }
  if (l > r || P[l] < ind) return -1;
  return P[l];
}
int Rec(int ind, int num) {
  if (num == 0) return -1;
  if (ind < 0) return -2;
  if (Save[ind][num] != -3) return Save[ind][num];
  int ret = -2;
  int tmp = Rec(ind - 1, num - 1);
  if (tmp != -2) {
    int next = Next(Pos[A[ind]], tmp + 1);
    if (next != -1) ret = next;
  }
  int tmp2 = Rec(ind - 1, num);
  if (tmp2 != -2 && (ret == -2 || tmp2 < ret)) ret = tmp2;
  return Save[ind][num] = ret;
}
int main() {
  cin >> n >> m >> s >> e;
  A.assign(n, 0);
  B.assign(m, 0);
  for (int i = 0; i < n; ++i) cin >> A[i];
  Save.assign(100001, vector<int>(310, -3));
  Pos.assign(100001, vector<int>());
  for (int i = 0; i < m; ++i) {
    cin >> B[i];
    Pos[B[i]].push_back(i);
  }
  int ret = 0;
  for (int j = 1; j <= int(s / e); ++j) {
    for (int i = 0; i < n; ++i) {
      int tmp = Rec(i, j);
      if (tmp == -2)
        continue;
      else
        tmp += i + 2;
      if (tmp <= s - j * e) ret = j;
    }
    if (ret < j) break;
  }
  cout << ret;
  return 0;
}
