#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  int count = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] <= x) {
      if (i == (n - 1)) {
        if (a[i] == x) {
          ++count;
        }
      } else {
        ++count;
        x -= a[i];
      }
    }
  }
  cout << count << endl;
}
