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