#include <bits/stdc++.h>
int main() {
  int i, N, x, a[101];
  scanf("%d %d", &N, &x);
  for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
  int count = 0, min, argmin, flag[101] = {};
  while (1) {
    min = 1000000001;
    argmin = 0;
    for (i = 1; i <= N; i++) {
      if (flag[i] == 0 && a[i] < min) {
        min = a[i];
        argmin = i;
      }
    }
    if (x < min)
      break;
    else {
      x -= min;
      flag[argmin] = 1;
      count++;
    }
  }
  printf("%d\n", count);
  fflush(stdout);
  return 0;
}
