#include <bits/stdc++.h>
int main(void) {
  long int a[1000], n, x, i, count = 0;
  scanf("%ld%ld", &n, &x);
  count = 0;
  for (i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  for (i = 0; i < n; i++) {
    if (a[i] <= x) {
      count++;
      x -= a[i];
    }
  }
  if (x != 0) {
    count--;
    printf("%ld", count);
  } else {
    printf("%ld", count);
  }
  return 0;
}
