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