#include <bits/stdc++.h>
int main(void) {
  int n, x, a[100], s, t, temp, count;
  scanf("%d%d", &n, &x);
  if (n >= 2) {
    for (s = 0; s < n; s++) {
      scanf("%d", &a[s]);
    }
    for (s = 0; s < n - 1; s++) {
      for (t = s; t < n; t++) {
        if (a[s] > a[t]) {
          temp = a[s];
          a[s] = a[t];
          a[t] = temp;
        }
      }
    }
    for (s = 0; s < n; s++) {
      if (x >= a[s]) {
        x = x - a[s];
        count = count + 1;
      } else {
        break;
      }
    }
    if (x > 0) count = count - 1;
    printf("%d", count);
  }
  return 0;
}
