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