#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a + N);
  int i = 0;
  while (x >= a[i] && i != N) {
    x -= a[i];
    i++;
  }
  printf("%d", i);
}
