#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
  if (a < 0) return (-a);
  return a;
}
void input() {}
void read(int &n) {
  n = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    n = n * 10 + ch - 48;
    ch = getchar();
  }
}
int a[100005], b[100005];
int dp[100005][305];
vector<int> v[100005];
int main() {
  input();
  int n, m, s, e;
  read(n);
  read(m);
  read(s);
  read(e);
  for (int i = (0); i < (n); ++i) read(a[i]);
  for (int i = (0); i < (m); ++i) {
    read(b[i]);
    v[b[i]].push_back(i);
  }
  int ans = 0;
  for (int i = (0); i < (302); ++i) dp[0][i] = 1000005;
  for (int i = (0); i < (n); ++i) dp[i][0] = -1;
  vector<int>::iterator it = upper_bound(v[a[0]].begin(), v[a[0]].end(), -1);
  if (it != v[a[0]].end()) {
    dp[0][1] = *it;
    if (dp[0][1] + 1 + 1 + e <= s) ans = 1;
  }
  for (int i = (1); i < (n); ++i) {
    for (int j = (1); j < (302); ++j) {
      dp[i][j] = 1000005;
      dp[i][j] = min(dp[i][j], dp[i - 1][j]);
      int ch = a[i];
      it = upper_bound(v[ch].begin(), v[ch].end(), dp[i - 1][j - 1]);
      if (it != v[ch].end()) dp[i][j] = min(dp[i][j], *it);
      if (dp[i][j] < 1000005) {
        int cost = e * j + i + dp[i][j] + 2;
        if (cost <= s) ans = max(ans, j);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
