#include <bits/stdc++.h>
using namespace std;
long long b[200], n, x, k, sum, s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    sum += b[i];
  }
  if (sum == x)
    cout << n;
  else {
    s += abs(sum - x);
    for (int i = 0; i < n; i++) {
      if (b[i] <= x && b[i] != s) {
        k++;
        x -= b[i];
      }
    }
    cout << k;
  }
  return 0;
}
