#include <bits/stdc++.h>
using namespace std;
vector<int> v[101000];
int n, m, s, e;
int dp[101000][310];
int a[101000], b[101000];
int main(void) {
  cin >> n >> m >> s >> e;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int j = 1; j <= m; ++j) cin >> b[j];
  for (int i = 1; i <= m; ++i) {
    v[b[i]].push_back(i);
  }
  for (int i = 0; i < 301; ++i) dp[0][i] = -1;
  for (int i = 0; i < 100100; ++i) dp[i][0] = 0;
  for (int i = 0; i < 100100; ++i) v[i].push_back(1010000);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 300; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (dp[i - 1][j - 1] != -1) {
        if (*lower_bound(v[a[i]].begin(), v[a[i]].end(),
                         dp[i - 1][j - 1] + 1) != 1010000 &&
            dp[i][j] != -1) {
          dp[i][j] = min(dp[i][j], *lower_bound(v[a[i]].begin(), v[a[i]].end(),
                                                dp[i - 1][j - 1] + 1));
        }
        if (*lower_bound(v[a[i]].begin(), v[a[i]].end(),
                         dp[i - 1][j - 1] + 1) != 1010000 &&
            dp[i][j] == -1) {
          dp[i][j] = *lower_bound(v[a[i]].begin(), v[a[i]].end(),
                                  dp[i - 1][j - 1] + 1);
        }
      }
    }
  }
  for (int j = 300; j >= 0; --j) {
    for (int i = 0; i <= n; ++i) {
      if (dp[i][j] != -1 && i + dp[i][j] + j * e <= s) {
        cout << j << endl;
        goto van;
      }
    }
  }
van:;
  return 0;
}
