#include <bits/stdc++.h>
using namespace std;
int n, x, happy, cand[111], sum;
int main() {
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n && scanf("%d", cand + i); i++)
    ;
  sort(cand, cand + n);
  sum = cand[0];
  if (sum > x) return printf("0"), 0;
  happy++;
  for (int i = 1; i < n; i++) {
    if (sum + cand[i] <= x) {
      happy++;
      sum += cand[i];
      continue;
    }
    break;
  }
  if (sum < x) happy--;
  printf("%d", happy);
}
