#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const int maxn = 100010;
int a[maxn], b[maxn];
int dp[333];
vector<int> point[maxn];
int main() {
  int n, m, s, e;
  scanf("%d%d%d%d", &n, &m, &s, &e);
  memset(dp, 0x3f, sizeof(dp));
  dp[0] = 0;
  for (int i = 0; i < maxn; i++) point[i].clear();
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < m; i++) scanf("%d", &b[i]), point[b[i]].push_back(i + 1);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = s / e; j >= 0; j--) {
      vector<int>::iterator it =
          upper_bound(point[a[i]].begin(), point[a[i]].end(), dp[j]);
      if (it == point[a[i]].end()) continue;
      dp[j + 1] = min(*it, dp[j + 1]);
      if (i + 1 + dp[j + 1] + (j + 1) * e <= s)
        ans = (ans > j + 1) ? ans : j + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
