#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n, x, a[200], ans;

int main() {
	scanf("%d%d",&n,&x);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	sort(a+1,a+n+1);
	for (int i=1;i<n;i++) if (a[i] <= x) x -= a[i], ++ans;  else break;
	if (x == a[n]) ++ans;
	printf("%d\n",ans);
}