#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ans = 0, flag = 0;
  int a[105];
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = 0; i < n - 1; i++) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }
  if (x != 0 && ans == n) ans--;
  printf("%d\n", ans);
  return 0;
}
