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