#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
ll mod = 1000000007;
int main() {
  ll n, x;
  cin >> n >> x;
  vll a(n);
  for (auto& i : a) cin >> i;
  sort(a.begin(), a.end());
  ll rem = x;
  ll ans = 0;
  while (ans < n || rem - a.at(ans) > 0) {
    rem -= a.at(ans);
    if (ans == n - 1 && rem != 0) break;
    ans++;
  }
  cout << ans << endl;
}
