#include <bits/stdc++.h>
using namespace std;
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
const int INF = 1 << 29;
int n;
const int N = 100005;
int a[N];
int b[N];
int dp[306][N];
vector<int> bIndex[N];
int findB(int i, int from) {
  vector<int>::iterator it =
      lower_bound(bIndex[i].begin(), bIndex[i].end(), from);
  return (it == bIndex[i].end()) ? INF : *it;
}
int main() {
  int ca, cb, sumE, e;
  scanf("%d %d", &ca, &cb);
  ;
  scanf("%d %d", &sumE, &e);
  ;
  a[0] = b[0] = 0;
  for (int i = (1); i <= (ca); i++) scanf("%d", &a[i]);
  ;
  for (int i = (1); i <= (cb); i++) scanf("%d", &b[i]);
  ;
  for (int i = (1); i <= (cb); i++) bIndex[b[i]].push_back(i);
  memset((dp[0]), (0), sizeof((dp[0])));
  for (int i = (1); i <= ((sumE / e) + 2); i++) {
    dp[i][0] = INF;
    for (int j = (1); j <= (ca); j++) {
      dp[i][j] = findB(a[j], dp[i - 1][j - 1] + 1);
      dp[i][j] = min(dp[i][j - 1], dp[i][j]);
    }
  }
  int out = 0;
  for (int i = (1); i <= ((sumE / e) + 2); i++) {
    for (int j = (1); j <= (ca); j++) {
      if (dp[i][j] == INF) continue;
      if (sumE - (e * i + j + dp[i][j]) >= 0) out = i;
    }
  }
  cout << out << endl;
  return 0;
}
