#include <bits/stdc++.h>
using namespace std;
int const N = 100000 + 10;
int n, m, s, e;
int a[N], b[N];
int dp[N][300 + 20];
vector<int> pos[N];
inline void dynamic_programming() {
  int max_times = s / e;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= max_times; ++j) {
      dp[i][j] = INT_MAX;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= max_times; ++j) {
      dp[i][j] = dp[i - 1][j];
      if (j >= 1) {
        int limit = dp[i - 1][j - 1];
        vector<int>::iterator it =
            upper_bound(pos[a[i]].begin(), pos[a[i]].end(), limit);
        if (it != pos[a[i]].end()) {
          dp[i][j] = min(dp[i][j], *it);
        }
      }
    }
  }
}
inline int get() {
  int max_times = s / e;
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= max_times; ++j) {
      if (dp[i][j] < INT_MAX && (i + dp[i][j] + j * e) <= s) {
        ans = max(ans, j);
      }
    }
  }
  return ans;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", b + i);
  }
  for (int i = 1; i <= m; ++i) {
    pos[b[i]].push_back(i);
  }
  dynamic_programming();
  printf("%d\n", get());
  return 0;
}
