#include <bits/stdc++.h>
using namespace std;
class ACandyDistributionAgain {
 public:
  void solve(istream& cin, ostream& cout) {
    long long int n, x;
    cin >> n >> x;
    vector<long long int> a;
    for (int i = 0; i < n; i++) {
      int tp;
      cin >> tp;
      a.push_back(tp);
    }
    long long int left = x;
    long long int done = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] <= left) {
        left -= a[i];
        done += 1;
      } else {
        bool fg = false;
        long long int m = a[i];
        for (int j = i - 1; j >= 0; j--) {
          if (a[j] > a[i]) fg = true;
          m = max(m, a[j]);
        }
        if (fg) {
          left = left - m + a[i];
        }
      }
    }
    if (left > 0 && done != 0) done -= 1;
    cout << done << '\n';
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  ACandyDistributionAgain solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
