#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1.0);
const double EPS = 1E-9;
const int INF = 2 * (1e+9) + 1;
const int NMAX = 1000000;
const int MOD = (1e+9) + 7;
int n, m, s, e;
int a[100100];
vector<int> b[100100];
int dp[301][100100];
int main() {
  cin >> n >> m >> s >> e;
  for (int i = 0; i < (n); ++i) cin >> a[i];
  for (int i = 0; i < (m); ++i) {
    int tmp;
    cin >> tmp;
    b[tmp].push_back(i);
  }
  int res = 0;
  for (int i = (0); i <= (n - 1); ++i) {
    dp[1][i] = INF;
    int cur = a[i];
    int pos_b = INF;
    if ((long long)(b[cur]).size()) {
      pos_b = b[cur][0];
    }
    dp[1][i] = pos_b;
    if (i) dp[1][i] = min(dp[1][i], dp[1][i - 1]);
    int need = dp[1][i] + i + 2 + e;
    if (need <= s) res = 1;
  }
  for (int i = (2); i <= (300); ++i) {
    for (int j = (0); j <= (i - 2); ++j) dp[i][j] = INF;
    for (int j = (i - 1); j <= (n - 1); ++j) {
      int val = upper_bound(b[a[j]].begin(), b[a[j]].end(), dp[i - 1][j - 1]) -
                b[a[j]].begin();
      int pos = INF;
      if (val != (long long)(b[a[j]]).size()) pos = b[a[j]][val];
      dp[i][j] = min(dp[i][j - 1], pos);
      int need = dp[i][j] + j + 2 + e * i;
      if (need <= s) res = max(res, i);
    }
  }
  cout << res;
}
