#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
int gcb(int a, int b) { return ((b == 0) ? a : gcb(b, a % b)); }
int gcd(int a, int b) { return (a * b) / gcb(a, b); }
int main() {
  int n;
  int ans = 0;
  ll x;
  vecll a;
  cin >> n >> x;
  for (int i = 0; i < (int)(n); ++i) {
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < (int)(n); ++i) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
