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