#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int a[maxn];
int b[maxn];
vector<int> vv[maxn];
int dp[305][maxn];
int minn[305][maxn];
int main() {
  int n, m, s, 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];
    vv[b[i]].push_back(i);
  }
  memset(minn, 0, sizeof minn);
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j <= n; j++) {
      minn[i][j] = 0x3f3f3f3f;
    }
  }
  memset(minn, 0, sizeof(minn));
  for (int i = 1; i <= 300; i++)
    for (int j = 0; j <= n; j++) minn[i][j] = 0x3f3f3f3f;
  int output = 0;
  for (int i = 1; i <= 300; i++) {
    for (int j = 1; j <= n; j++) {
      int pre = minn[i - 1][j - 1];
      minn[i][j] = minn[i][j - 1];
      int ans = -1;
      int l = 0;
      int r = vv[a[j]].size() - 1;
      while (r - l >= 0) {
        if (vv[a[j]][((l + r) >> 1)] > pre) {
          ans = vv[a[j]][((l + r) >> 1)];
          r = ((l + r) >> 1) - 1;
        } else
          l = ((l + r) >> 1) + 1;
      }
      if (ans == -1) continue;
      if (i * e + j + ans <= s) output = i;
      minn[i][j] = min(minn[i][j - 1], ans);
    }
  }
  cout << output << endl;
  int ans = 0;
  return 0;
}
