#include <bits/stdc++.h>
using namespace std;
int a[110], n, x;
int main() {
  while (scanf("%d %d", &n, &x) != EOF) {
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (x >= a[i]) {
        ans++;
        x -= a[i];
      }
    }
    if (ans) ans -= (x > 0);
    printf("%d\n", ans);
  }
  return 0;
}
