#include <bits/stdc++.h>
using namespace std;
const int MAXN = 45000 + 10;
const int MAX = 1e7;
double pi = 3.1415926535897932384626433832795;
const long long inf = 1e18;
int main() {
  int N;
  cin >> N;
  long long x;
  cin >> x;
  long long a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int cnt = 0;
  for (int i = 0; i < N; i++)
    if (x - a[i] >= 0) {
      x -= a[i];
      cnt++;
    }
  if (x > 0) {
    cnt--;
  }
  cout << cnt << endl;
  return 0;
}
