#include <bits/stdc++.h>
int main() {
  int n, x, i, tmp, flag = 0, count = 0, a[110] = {};
  scanf("%d %d", &n, &x);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  do {
    flag = 0;
    for (i = 0; i < n - 1; i++) {
      if (a[i] > a[i + 1]) {
        tmp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = tmp;
        flag = 1;
      }
    }
  } while (flag == 1);
  i = 0;
  flag = 0;
  while (x - a[i] >= 0) {
    x -= a[i];
    count++;
    i++;
    flag = 1;
    if (i >= n) break;
  }
  if (x > 0 && flag == 1) count--;
  printf("%d", count);
  return 0;
}
