#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 123;
int n, m, s, e;
int a[maxn];
vector<int> nb[maxn];
int dp[maxn][300];
int ans;
int main() {
  scanf("%d%d%d%d", &n, &m, &s, &e);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int j = 1; j <= m; ++j) {
    int x;
    scanf("%d", &x);
    nb[x].push_back(j);
  }
  int maxi = s / e;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    if (nb[a[i]].size() == 0)
      dp[i][1] = -1;
    else
      dp[i][1] = nb[a[i]][0];
    if (dp[i][1] != -1) {
      if (s - e - i - dp[i][1] >= 0) ans = 1;
    }
  }
  for (int i = 2; i <= maxi; ++i) {
    int minn = dp[i - 1][i - 1];
    for (int j = i; j <= n; ++j) {
      if (minn == -1)
        dp[j][i] = -1;
      else {
        vector<int> &tv = nb[a[j]];
        vector<int>::iterator it = upper_bound(tv.begin(), tv.end(), minn);
        if (it != tv.end())
          dp[j][i] = *it;
        else
          dp[j][i] = -1;
      }
      if (dp[j][i - 1] != -1) {
        if (minn == -1 || dp[j][i - 1] < minn) minn = dp[j][i - 1];
      }
      if (dp[j][i] != -1) {
        if (s - i * e - j - dp[j][i] >= 0) ans = i;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
