#include <bits/stdc++.h>
const long INF = 1000000009;
const long LINF = 1123456789012345678;
long n, x;
long a[105];
signed main() {
  scanf("%ld %ld", &n, &x);
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  std::sort(a, a + n);
  for (long i = 0; i < n; i++) {
    if (a[i] == x) {
      printf("%ld\n", i + 1);
      return 0;
    } else if (a[i] > x) {
      printf("%ld\n", i);
      return 0;
    } else {
      x -= a[i];
    }
  }
  printf("%ld\n", n);
  return 0;
}
