#include <bits/stdc++.h>
const int Maxv = 110;
int num[Maxv], ans, n, k;
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &num[i]);
  std::sort(num + 1, num + n + 1);
  for (int i = 1; i <= n; i++) {
    k -= num[i];
    if (k < 0) break;
    ans++;
  }
  if (k) ans--;
  printf("%d\n", ans);
  return 0;
}
