#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <string>

using namespace std;
#define M 110

int main(){
  int N, i, x, a[M];
  cin >> N >> x;
  for (i = 0; i < N; i++)
    cin >> a[i];
  int sum=0;
  sum =  accumulate(a, a+N, sum);
  if (sum == x){
    cout << N << endl;
    return 0;
  }else if (sum < x){
    cout << N-1 << endl;
    return 0;
  }
  sort(a, a+N);
  // for (i = 0; i < N; i++)
  //   cout << a[i] << " ";
  cout << endl;
  i = 0;
  while (x >= a[i]){
    x -= a[i];
    i++;
  }
  cout << i << endl;
  return 0;
}
