#include <bits/stdc++.h>
#pragma optimization_level 3
using namespace std;
const long long mod = 1000000007;
const long long MAX = 222222;
const long long MAXD = 411111;
const long long INF = 1e18;
struct usual {
  long long x, y, z;
};
long long a[MAX];
int main() {
  long long n;
  long long x;
  cin >> n >> x;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      x -= a[i];
      sum++;
    }
  }
  if (sum == n && x >= 0) sum--;
  cout << sum << endl;
  return 0;
}
