#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> 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])
      break;
    else {
      x -= a[i];
      cnt++;
    }
  }
  if (x > 0 && cnt == 0)
    cout << 0 << endl;
  else if (x > 0)
    cout << cnt - 1 << endl;
  else
    cout << cnt << endl;
}
