#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e5 + 10, MaxA = 310, End = 1e6;
int n, m, s, e, a[MaxN], b[MaxN];
int dp[MaxN][MaxA], mini[MaxN], sol;
vector<int> pos[MaxN];
int find(int val, int minp) {
  if (minp == End) return End;
  int lo = 0, hi = pos[val].size(), mid;
  while (lo < hi) {
    mid = (lo + hi) / 2;
    if (pos[val][mid] <= minp)
      lo = mid + 1;
    else
      hi = mid;
  }
  return pos[val][lo];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> s >> e;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) {
    cin >> b[i];
    pos[b[i]].push_back(i);
  }
  for (int i = 0; i < MaxN; i++) {
    mini[i] = End;
    pos[i].push_back(End);
  }
  for (int i = 0; i < n; i++)
    for (int j = MaxA - 1; j > 0; j--) {
      if (j == 1)
        dp[i][j] = find(a[i], -1);
      else
        dp[i][j] = find(a[i], mini[j - 1]);
      mini[j] = min(mini[j], dp[i][j]);
      if ((long long)e * j + dp[i][j] + 1 + i + 1 <= s) sol = max(sol, j);
    }
  cout << sol;
  return 0;
}
