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