#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, child[110], i, count = 0;
  cin >> N >> x;
  for (i = 0; i < N; i++) cin >> child[i];
  sort(child, child + N);
  for (i = 0; i < N; i++) {
    if (x >= child[i]) {
      x -= child[i];
      count++;
    }
  }
  if (x > 0) count--;
  cout << count << endl;
}
