#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1000000007;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  a[n] = 1000100100;
  sort((a).begin(), (a).end());
  int c = 0;
  while (c < n && x > 0) {
    if (a[c] > x) {
      break;
    }
    x -= a[c];
    if (x != 0 && a[c + 1] > x) {
      break;
    }
    c++;
  }
  cout << c << endl;
}
