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