main()
{ 
  #ifdef CP
    freopen("/home/tarun/Desktop/input.txt", "r", stdin);
//    freopen("/home/tarun/Desktop/output.txt", "w", stdout);
  #endif
  //cerr << fixed << setprecision(18);
  sync;
  clock_t clk = clock();
  cerr << "I will return...\n";
  
  int n; cin >> n;
  int x; cin >> x;
  int a[n];
  for(int&i : a) cin >> i;
  sort(a, a + n);
  int cnt = 0;
  int i = 0;
  while(i < n && x > 0) {
    x -= a[i];
    i++;
    cnt++;
  }
  //db(x);
  if(x) cout << cnt - 1 << '\n';
  else cout << cnt << '\n';


  cerr << "...don't you ever hang your head.\n";
  cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}