#include <bits/stdc++.h>
int n;
unsigned long x, a[INT_MAX / 10];
int main() {
  int i, j, k;
  int count = 0;
  scanf("%d%lu", &n, &x);
  for (i = 0; i < n; i++) {
    scanf("%lu", &a[i]);
  }
  for (i = 0; i < n; i++) {
    k = i;
    for (j = i; j < n; j++) {
      if (a[i] > a[j]) {
        k = j;
      }
    }
    unsigned long temp = a[k];
    a[k] = a[i];
    a[i] = temp;
  }
  i = 0;
  while (x >= a[i] && a[i] > 0) {
    x = x - a[i];
    i++;
    count++;
  }
  if (x != 0) count--;
  if (count < 0) count = 0;
  printf("%d\n", count);
  return 0;
}
