#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, a;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (x - v[i]) break;
    cnt++;
    x -= v[i];
  }
  cout << cnt << endl;
  return 0;
}
