#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int child[maxn];
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%d", child + i);
  sort(child, child + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= child[i]) {
      x -= child[i];
      ans++;
    } else {
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
