#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn], n, c, res = 0;
int main() {
  scanf("%d %d", &n, &c);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int j = 0;
  while (c > 0 && j < n) {
    if (c >= a[j])
      res += 1, c -= a[j];
    else
      break;
    j++;
  }
  printf("%d", res);
}
