#include <bits/stdc++.h>
using namespace std;
const int N = 100 * 1000 + 20;
long long int a[N], b[N], dp[310][N];
vector<int> ind[N];
const long long int inf = INT_MAX;
int main() {
  long long int n, m, s, e;
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    ind[b[i]].push_back(i);
  }
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (ind[a[i]].empty()) {
      dp[1][i] = inf;
    } else {
      dp[1][i] = ind[a[i]][0];
    }
    if (i + 1 + dp[1][i] + 1 + e <= s) {
      ans = 1;
    }
  }
  for (int i = 2; i < 301; i++) {
    long long int mn = inf;
    for (int j = 0; j < n; j++) {
      int x = upper_bound(ind[a[j]].begin(), ind[a[j]].end(), mn) -
              ind[a[j]].begin();
      if (x == ind[a[j]].size()) {
        dp[i][j] = inf;
      } else {
        dp[i][j] = ind[a[j]][x];
      }
      if (j + 1 + dp[i][j] + 1 + i * e <= s) {
        ans = i;
      }
      mn = min(mn, dp[i - 1][j]);
    }
  }
  cout << ans << "\n";
}
