#include <bits/stdc++.h>
using namespace std;
const int maxn = 10000 + 50;
long long s[maxn];
int main() {
  long long n, x, sum, p = 0;
  cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    sum = sum + s[i];
  }
  if (sum == x)
    printf("%lld\n", n);
  else if (x > sum)
    printf("%lld\n", n - 1);
  else {
    sort(s, s + n);
    for (int i = 1; i <= n; ++i) {
      if (x >= s[i]) {
        p++;
        x = x - s[i];
      }
    }
    printf("%lld\n", p);
  }
  return 0;
}
