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