#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
vector<int> aa[N + 1];
const int inf = 1e9;
int get(int x, int l) {
  auto it = upper_bound(aa[x].begin(), aa[x].end(), l);
  if (it == aa[x].end()) {
    return inf;
  }
  return *it + 1;
}
int main() {
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int b[m];
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    aa[a[i]].push_back(i);
  }
  int k = s / e;
  k = min(k, min(n, m));
  if (k == 0) {
    cout << "0\n";
    return 0;
  }
  int dp[m + 1][k + 1];
  int mi[k + 1];
  for (int i = 0; i <= m; ++i) {
    dp[i][0] = 0;
  }
  for (int i = 0; i <= k; ++i) {
    mi[i] = inf;
  }
  mi[0] = -1;
  for (int i = 1; i <= k; ++i) {
    dp[0][i] = inf;
  }
  for (int i = 1; i <= m; ++i) {
    int mi_tmp[k + 1];
    for (int j = 0; j <= k; ++j) {
      mi_tmp[j] = inf;
    }
    for (int j = 1; j <= k; ++j) {
      if (j > i) {
        dp[i][j] = inf;
        continue;
      }
      dp[i][j] = get(b[i - 1], mi[j - 1]);
      if (dp[i][j] != inf) mi_tmp[j] = min(mi_tmp[j], dp[i][j] - 1);
    }
    for (int j = 0; j <= k; ++j) {
      mi[j] = min(mi[j], mi_tmp[j]);
    }
  }
  int ans = 0;
  for (int i = 1; i <= k; ++i) {
    int cur = inf;
    for (int j = i; j <= m; ++j) {
      cur = min(cur, j + dp[j][i]);
    }
    if (cur + i * e <= s) {
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
