#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,x,*a=map(int,open(0).read().split());c=0\n"
"for t in sorted(a):\n"
"  x-=t\n"
"  if x<0:break\n"
"  c+=1\n"
"print(c-(x>0))\n"
"\"";
  system(s);
  return 0;
}            