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