#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  int a[101] = {};
  int dpmax[101] = {};
  int dpama[101] = {};
  cin >> N >> x;
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  dpmax[1] = x >= a[1] ? 1 : 0;
  dpama[1] = x >= a[1] ? x - a[1] : x;
  int jmax = 0, amax = 0, jnum = 0;
  for (int i = 2; i <= N; i++) {
    jmax = 0;
    amax = 0;
    for (int j = 1; j < i; j++) {
      if (dpama[j] >= a[i]) {
        if (jmax < dpmax[j] + 1) {
          jmax = dpmax[j] + 1;
          amax = dpama[j] - a[i];
        } else if (jmax == dpmax[j] + 1) {
          if (amax <= dpama[j] - a[i]) {
            amax = dpama[j] - a[i];
          }
        } else {
        }
      } else {
        if (jmax < dpmax[j]) {
          jmax = dpmax[j];
          amax = dpama[j];
        } else if (jmax == dpmax[j] + 1) {
        } else {
        }
      }
    }
    dpmax[i] = jmax;
    dpama[i] = amax;
  }
  if (dpama[N] > 0) {
    if (dpmax[N] == N)
      dpmax[N]--;
    else
      ;
  }
  cout << dpmax[N] << endl;
  return 0;
}
