#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int dp[N][310], c[N][310], lst[N], a[N], b[N];   vector<int> v[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, s, e;     cin >> n >> m >> s >> e;     for (int i = 0; i < n; i++) {       cin >> a[i + 1];     }     for (int i = 0; i < m; i++) {       cin >> b[i + 1];       v[b[i + 1]].push_back(i + 1);     }     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= 300; j++) {         dp[i][j] = -1;       }       lst[i] = -1;     }     lst[0] = 0;     for (int i = 1; i <= n; i++) {       for (int j = min(300, n); j >= 1; j--) {         if (lst[j - 1] == -1 || v[a[i]].size() == 0) continue;         if (v[a[i]].back() <= lst[j - 1]) continue;         int ind = upper_bound(v[a[i]].begin(), v[a[i]].end(), lst[j - 1]) -                   v[a[i]].begin();         dp[i][j] = v[a[i]][ind];         c[i][j] = e * j + dp[i][j] + i;         if (lst[j] == -1)           lst[j] = v[a[i]][ind];         else           lst[j] = min(v[a[i]][ind], lst[j]);       }     }     int ans = n;     for (int i = n; i >= 0; i--) {       if (lst[i] != -1) {         ans = i;         break;       }     }     for (int j = ans; j >= 1; j--) {       int k = 1000000000;       for (int i = 1; i <= n; i++) {         if (dp[i][j] != -1) {           k = min(k, c[i][j]);         }       }       if (k <= s) {         cout << j;         return 0;       }     }     cout << 0;   }   