#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, h;
  int l, r;
  vector<int> wake;
  cin >> n >> h >> l >> r;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    wake.push_back(x);
  }
  int res = 0;
  vector<pair<int, int> > res_array(h, pair<int, int>(0, -1));
  res_array[0].second = 0;
  for (int i = 0; i < n; i++) {
    vector<int> tmp(h, 0);
    vector<bool> mark(h, false);
    for (int j = 0; j < h; j++) {
      if (res_array[j].second != i) continue;
      int pos1, pos2;
      pos1 = (j + wake[i]) % h;
      pos2 = (j + wake[i] - 1) % h;
      int tmp_v;
      if (pos1 <= r && pos1 >= l)
        tmp_v = (res_array[j].first + 1);
      else
        tmp_v = res_array[j].first;
      if (tmp_v > tmp[pos1]) tmp[pos1] = tmp_v;
      mark[pos1] = true;
      if (pos2 <= r && pos2 >= l)
        tmp_v = (res_array[j].first + 1);
      else
        tmp_v = res_array[j].first;
      if (tmp_v > tmp[pos2]) tmp[pos2] = tmp_v;
      mark[pos2] = true;
    }
    for (int j = 0; j < h; j++) {
      if (mark[j]) {
        res_array[j].first = tmp[j];
        res_array[j].second = i + 1;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    if (res_array[i].first > res) res = res_array[i].first;
  }
  cout << res;
  return 0;
}
