#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
using namespace std;
#define INF 2001001001
#define MOD 1000000007
typedef long long ll;

ll N,X;
ll arr[101];

int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  cin>>N>>X;
  for (int i=0;i<N;i++)
    cin>>arr[i];
  sort(arr,arr+N);
  ll ans=0;
  for (int i=0;i<N;i++)
    if (X-arr[i]>=0){
      X-=arr[i];
      ans++;
    }
  if (X>0)
    ans--;
  ans=max(ans,0);
  cout<<ans<<endl;
  return 0;
}
