#include <bits/stdc++.h>
using namespace std;
const int N = 1000000 + 7;
const int M = 32;
const long long base = 1e18;
const int mod = 999983;
const int inf = 1e9 + 7;
const double pi = acos(-1);
const int maxn = N * 2;
const double PI = acos(-1);
const double ep = 1e-9;
int n, m, s, e;
int a[N], b[N];
int last[N];
map<int, int> st;
vector<int> all[N];
int dp[2][N];
int getPos(int x) {
  if (st.count(x))
    return st[x];
  else
    return st[x] = st.size();
}
void solve() {
  cin >> n >> m >> s >> e;
  for (int i = (0); i < (n); i++) scanf("%d", a + i);
  for (int j = (0); j < (m); j++) {
    scanf("%d", b + j);
    all[getPos(b[j])].push_back(j);
  }
  last[0] = -1;
  for (int i = (1); i < (N); i++) last[i] = inf;
  int C = s / e;
  int ans = 0;
  for (int i = (0); i < (n); i++) {
    if (st.count(a[i])) {
      int c = st[a[i]];
      for (int j = C - 1; j >= 0; j--) {
        typeof(all[c].begin()) it =
            lower_bound(all[c].begin(), all[c].end(), last[j] + 1);
        if (it != all[c].end()) {
          if ((j + 1) * e + (i + 1 + (*it) + 1) <= s) {
            ans = max(ans, j + 1);
          }
          last[j + 1] = min(last[j + 1], *it);
        }
      }
    }
  }
  cout << ans;
}
int main() {
  int T = 1;
  for (int i = (1); i < (T + 1); i++) {
    solve();
  }
}
