#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, k, a, b, c, cc[500000];
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", cc[i]);
  }
  sort(cc + 1, cc + n + 1);
  for (int i = 1; i <= n; i++) {
    if (m >= cc[i]) {
      k++;
      m -= cc[i];
    }
  }
  printf("%d\n", k);
  return 0;
}
