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