#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  static int p;
  p = 1;
  static char c;
  c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c - 48);
    c = getchar();
  }
  x *= p;
}
int n, sum;
int a[110];
int main() {
  read(n);
  read(sum);
  for (int i = 1; i <= n; i++) read(a[i]);
  int tot = 0;
  for (int i = 1; i <= n && sum; i++)
    if (sum >= a[i]) sum -= a[i], tot++;
  if (sum && tot == n) tot--;
  cout << tot << endl;
  return 0;
}
