#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int M = 1e6 + 5;
const int MAX = 5;
const long long inv = 500000004;
const double g = 9.80;
const double PI = acos(-1.0);
int n;
long long sum;
long long a[N];
int main() {
  while (scanf("%d %lld", &n, &sum) != EOF) {
    for (int i = 1; i < n + 1; i++) scanf("%lld", a + i);
    sort(a + 1, a + n + 1);
    if (sum < a[1]) {
      printf("0\n");
      continue;
    }
    bool flag = 0;
    int ans = 0;
    for (int i = 1; i < n + 1; i++) {
      if (sum - a[i] < 0) break;
      if (sum - a[i] == 0) flag = 1;
      sum -= a[i];
      ans++;
    }
    if (!flag) ans--;
    printf("%d\n", ans);
  }
  return 0;
}
