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