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