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