#include <bits/stdc++.h>
using namespace std;
const int Inf = 999999;
int n, m, s, e, ans;
int num[100002];
vector<int> V[100002];
pair<int, int> dp[302];
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  for (int i = 1; i <= m; i++) {
    int b;
    scanf("%d", &b);
    V[b].push_back(i);
  }
  int Max = s / e;
  dp[0].second = -1;
  for (int i = 1; i <= n; i++)
    for (int j = Max; j >= 0; j--)
      if (dp[j].second) {
        for (vector<int>::iterator iter = V[num[i]].begin();
             iter != V[num[i]].end(); iter++)
          if ((*iter) > dp[j].second) {
            if (dp[j + 1].first == 0 || dp[j + 1].second > (*iter)) {
              dp[j + 1].first = i;
              dp[j + 1].second = (*iter);
              if (i + (*iter) + (j + 1) * e <= s) ans = max(ans, j + 1);
            }
            break;
          }
      }
  printf("%d\n", ans);
  return 0;
}
