#include <bits/stdc++.h>
int main() {
  long long int n, x, i, j, min, temp, sum = 0, count = 0, d = 1;
  scanf("%lld%lld", &n, &x);
  long long int a[n + 10];
  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }
  min = a[0];
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (a[0] > a[j]) {
        temp = a[i];
        a[i] = a[j];
        a[j] = temp;
      }
    }
  }
  for (i = 0; i < n; i++) {
    x -= a[i];
    if (x >= 0) {
      if (x > 0 && i == n - 1) {
        int d = -1;
        break;
      } else
        count++;
    }
  }
  printf("%d", count);
}
