#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e7;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  int sum = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> v[i];
    sum += v[i];
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  } else {
    sort((v).begin(), (v).end());
    int i = 0;
    int cc = 0;
    while (i < n && x >= v[i]) {
      x -= v[i];
      cc++;
      i++;
    }
    if (i == n) {
      cc--;
    }
    cout << cc << endl;
  }
}
