#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long x;
  cin >> x;
  long long arr[n];
  int i, j;
  int count = 0;
  bool f[n];
  for (i = 0; i < n; ++i) {
    cin >> arr[i];
    if (arr[i] > x)
      f[i] = false;
    else
      f[i] = true;
  }
  long long sum = 0;
  int c = 0;
  for (i = 0; i < n; i++) {
    if (f[i]) {
      sum += arr[i];
      if (sum > x) break;
      c++;
    }
  }
  cout << c;
  return 0;
}
