#include <bits/stdc++.h>
int main(void) {
  int n, x;
  scanf("%d %d", &n, &x);
  int a[100];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    for (int j = i - 1; j >= 0; j--) {
      if (a[j] > a[j + 1]) {
        int aa = a[j];
        a[j + 1] = a[j];
        a[j] = aa;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  printf("%d", ans);
}
