#include <bits/stdc++.h>
using namespace std;
int MODP(long long x) {
  int r = x % 1000000007;
  if (r < 0) r += 1000000007;
  return r;
}
void testGen() {
  freopen("biginput1.txt", "w", stdout);
  fclose(stdout);
}
template <class T>
class LongestCommonSubsequence {
  vector<int> seq1, seq2;
  int l1, l2, upper, longest;
  vector<vector<int>> pos;
  unordered_map<T, int> valueMap;
  void discretize(const vector<T> &s1, const vector<T> &s2) {
    int idx = 0;
    for (auto &x : s1) {
      if (!valueMap.count(x)) {
        valueMap[x] = idx;
        idx++;
      }
    }
    for (auto &x : s2) {
      if (!valueMap.count(x)) {
        valueMap[x] = idx;
        idx++;
      }
    }
    l1 = (int)s1.size();
    l2 = (int)s2.size();
    upper = min(upper, l1);
    upper = min(upper, l2);
    seq1.resize(l1);
    seq2.resize(l2);
    for (auto i = 0; i < l1; ++i) {
      seq1[i] = valueMap[s1[i]];
    }
    for (auto i = 0; i < l2; ++i) {
      seq2[i] = valueMap[s2[i]];
    }
  }

 public:
  LongestCommonSubsequence(const vector<T> &s1, const vector<T> &s2,
                           int upper) {
    this->upper = upper;
    discretize(s1, s2);
    pos.resize(upper + 1, vector<int>(l1));
    int numValues = (int)valueMap.size();
    vector<int> minPos(numValues, l2);
    for (auto j = l2 - 1; j >= 0; --j) {
      minPos[seq2[j]] = j;
    }
    longest = 0;
    if (minPos[seq1[0]] < l2) {
      pos[1][0] = minPos[seq1[0]];
      longest = 1;
    } else {
      pos[1][0] = l2;
    }
    for (auto i = 1; i <= l1 - 1; ++i) {
      pos[1][i] = pos[1][i - 1];
      if (minPos[seq1[i]] < l2) {
        pos[1][i] = min(pos[1][i], minPos[seq1[i]]);
      }
    }
    for (auto l = 2; l <= upper; ++l) {
      pos[l][0] = l2;
      int leftIndex = l2;
      for (auto x = 0; x < numValues; ++x) {
        minPos[x] = l2;
      }
      for (auto i = 1; i <= l1 - 1; ++i) {
        pos[l][i] = pos[l][i - 1];
        if (pos[l - 1][i - 1] != l2) {
          int newLeftIndex = pos[l - 1][i - 1] + 1;
          for (auto j = leftIndex - 1; j >= newLeftIndex; --j) {
            minPos[seq2[j]] = j;
          }
          leftIndex = newLeftIndex;
          if (minPos[seq1[i]] < l2) {
            pos[l][i] = min(pos[l][i], minPos[seq1[i]]);
          }
        }
        if (pos[l][i] != l2) {
          longest = l;
        }
      }
    }
  }
  int getLongest() const { return longest; }
  bool hasLCS(int i, int l) const {
    if (l > upper) return false;
    return pos[l][i] != l2;
  }
  int getMinPos(int i, int l) const {
    assert(hasLCS(i, l));
    return pos[l][i];
  }
};
int l1, l2, s, e;
vector<int> s1, s2;
int main() {
  cin >> l1 >> l2 >> s >> e;
  int x;
  for (auto repeat_var = 0; repeat_var < l1; ++repeat_var) {
    cin >> x;
    s1.push_back(x);
  }
  for (auto repeat_var = 0; repeat_var < l2; ++repeat_var) {
    cin >> x;
    s2.push_back(x);
  }
  if (s1.size() > s2.size()) {
    swap(s1, s2);
    swap(l1, l2);
  }
  int maxCS = s / e;
  LongestCommonSubsequence<int> lcs(s1, s2, maxCS);
  int best = 0;
  for (auto l = 1; l <= maxCS; ++l) {
    int remainingEnergy = s - l * e;
    for (auto i = 0; i < l1; ++i) {
      if (lcs.hasLCS(i, l)) {
        int j = lcs.getMinPos(i, l);
        if (i + 1 + j + 1 <= remainingEnergy) {
          best = l;
          break;
        }
      }
    }
  }
  cout << best << endl;
  return 0;
}
