#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n;
  cin >> n;
  long long x;
  cin >> x;
  long long a[111];
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum == x)
    cout << n << endl;
  else if (sum > x)
    cout << n - 1 << endl;
  else {
    sort(a, a + n);
    long long cnt = 0;
    for (long long i = 0; i < n; i++) {
      if (x >= a[i]) {
        cnt++;
        x -= a[i];
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
