#include <bits/stdc++.h>
int n, x, a[100], res;
int main() {
  std::cin >> n;
  for (int i = 0; i < n; i++) std::cin >> a[i];
  std::sort(a, a + n);
  for (int i = 0; i < n; i++)
    if (x >= a[i])
      x -= a[i], res++;
    else
      break;
  std::cout << res;
}
