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