#include <bits/stdc++.h>
using namespace std;
inline void setmin(int &x, int y) {
  if (y < x) x = y;
}
inline void setmax(int &x, int y) {
  if (y > x) x = y;
}
inline void setmin(long long &x, long long y) {
  if (y < x) x = y;
}
inline void setmax(long long &x, long long y) {
  if (y > x) x = y;
}
const int N = 100000;
const int inf = (int)1e9 + 1;
const long long big = (long long)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;
vector<int> pos[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  int n, m, s, e;
  cin >> n >> m >> s >> e;
  int a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    b[i]--;
    pos[b[i]].push_back(i);
  }
  int cnt = s / e;
  int dp[n][cnt + 1];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < cnt + 1; j++) dp[i][j] = inf;
  for (int i = 0; i < n; i++) {
    int p = 0;
    dp[i][0] = -1;
    for (int j = 1; j < min(i + 1, cnt) + 1; j++) {
      if (i > 0) setmin(dp[i][j], dp[i - 1][j]);
      int last_pos = (i == 0 ? -1 : dp[i - 1][j - 1]);
      while (p < (int)pos[a[i]].size() && pos[a[i]][p] <= last_pos) p++;
      if (p < (int)pos[a[i]].size()) setmin(dp[i][j], pos[a[i]][p]);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < cnt + 1; j++)
      if ((i + 1) + (dp[i][j] + 1) + j * e <= s) setmax(ans, j);
  cout << ans << "\n";
  return 0;
}
