#include <iostream>
#include <cstdio>
using namespace std;
int N, M;
int MOD;
int Fact[6005], Inv[6005], Pw2[6005], Pw3[6005], IPw2[6005], IPw3[6005];
int power(int n, int p){
    int sol = 1;
    while(p){
        if(p & 1)
            sol = (1LL * sol * n) % MOD;
        p /= 2;
        n = (1LL * n * n) % MOD;
    }
    return sol;
}
void precalcFact(){
    Fact[0] = 1;
    for(int i = 1; i <= N * 3; i++){
        Fact[i] = (1LL * Fact[i - 1] * i) % MOD;
    }
    Inv[N * 3] = power(Fact[N * 3], M - 2);
    for(int i = N * 3 - 1; i >= 0; i--)
        Inv[i] = (1LL * Inv[i + 1] * (i + 1)) % MOD;
}

void precalcPower(){
    Pw2[0] = 1;
    Pw3[0] = 1;
    IPw2[0] = 1;
    IPw3[0] = 1;
    for(int i = 1; i <= N * 3; i++){
        Pw2[i] = (1LL * Pw2[i - 1] * 2) % MOD;
        Pw3[i] = (1LL * Pw3[i - 1] * 3) % MOD;
        IPw2[i] = power(Pw2[i], M - 2);
        IPw3[i] = power(Pw3[i], M - 2);
    }
}
int compute(int p1, int p2, int p3){
    int ans = Fact[3 * N];
    ans = (1LL * ans * Inv[p1]) % MOD;
    ans = (1LL * ans * Inv[p2]) % MOD;
    ans = (1LL * ans * Inv[p3]) % MOD;
    ans = (1LL * ans * IPw2[p2]) % MOD;
    ans = (1LL * ans * IPw3[p3]) % MOD;
    return ans;
}
void Solve(){
    int ans = 0;
    for(int i = 0; i <= N * 3; i++){
        for(int j = 0; j <= N * 3; j++){
            int g1 = 3 * N - 2 * i - 3 * j;
            if(g1 < i)
                break;
            ans += compute(g1, i, j);
            if(ans >= MOD)
                ans -= MOD;
        }
    }
    cout << ans << '\n';
}
int main()
{
    cin >> N >> M;
    MOD = M;
    precalcFact();
    precalcPower();
    Solve();
    return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

signed main() {
  init();
  ll N, M, V, P;
  cin >> N >> M >> V >> P;
  vll A(N);
  cin >> A;
  RSORT(A);

  ll left = 0, right = N;
  while (right - left > 1) {
    ll center = (left + right) / 2;
    if (center < P) {
      left = center;
      continue;
    }

    ll after = A[center] + M;

    if (after < A[P - 1]) {
      right = center;
      continue;
    }

    ll num = ((P - 1) + 1 + N - (center + 1)) * M;
    rep2(i, P - 1, center) num += after - A[i];

    if (num < M * V)
      right = center;
    else
      left = center;
  }

  COUT(left + 1);
  return 0;
}