#include <bits/stdc++.h>
using namespace std;
int n, m, s, e;
int a[100100], b[100100], dp[100100][301], ans;
vector<int> pos[100100];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &s, &e);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int j = 1; j <= m; j++) {
    scanf("%d", &b[j]);
    pos[b[j]].push_back(j);
  }
  for (int i = 1; i <= 300; i++) {
    for (int j = 0; j <= n; j++) {
      dp[j][i] = 1000000;
    }
  }
  for (int i = 0; i <= 300; i++) {
    for (int j = 0; j < n; j++) {
      int p = lower_bound(pos[a[j + 1]].begin(), pos[a[j + 1]].end(),
                          dp[j][i] + 1) -
              pos[a[j + 1]].begin();
      dp[j + 1][i] = min(dp[j + 1][i], dp[j][i]);
      if (p < pos[a[j + 1]].size() and
          ((i + 1) * e + j + 1 + pos[a[j + 1]][p]) <= s) {
        dp[j + 1][i + 1] = min(dp[j + 1][i + 1], pos[a[j + 1]][p]);
        ans = i + 1;
      }
    }
  }
  cout << ans << endl;
  ;
  return 0;
}
