#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long x;
  cin >> x;
  vector<long long> a(N);
  long long sum = 0;
  for (int i = 0; i < (N); i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if (sum == x) {
    cout << N << endl;
    return 0;
  }
  int count = 0;
  int ans = 0;
  for (int i = 0; i < (N); i++) {
    int tmp = 0;
    for (int j = 0; j <= i; j++) {
      tmp += a[j];
    }
    if (tmp <= x) {
      ans = i + 1;
    }
  }
  if (ans == N) {
    cout << N - 1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
