#include <bits/stdc++.h>
using namespace std;
void ft_swap(long *a, long *b) {
  long tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}
void ft_qsort(long *tab, long left, long right) {
  long L, R;
  long pivot;
  L = left, R = right;
  pivot = tab[(L + R) / 2];
  while (1) {
    while (tab[L] > pivot) L++;
    while (tab[R] < pivot) R--;
    if (L >= R) break;
    ft_swap(&tab[L], &tab[R]);
    R--;
    L++;
  }
  if (L - 1 > left) ft_qsort(tab, left, L - 1);
  if (R + 1 < right) ft_qsort(tab, R + 1, right);
}
int main() {
  long n, x;
  cin >> n >> x;
  long a[n];
  long i = 0;
  while (i < n) {
    cin >> a[i];
    i++;
  }
  i = 0;
  int count = 0;
  while (i < n) {
    if (i != n - 1) {
      if (x >= a[i]) {
        x -= a[i];
        count++;
      }
    } else {
      if (x - a[i] == 0) {
        x -= a[i];
        count++;
      }
    }
    if (x == 0) break;
    i++;
  }
  printf("%d", count);
  return 0;
}
