#include <bits/stdc++.h>
using namespace std;
int main() {
  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;
  int count = 0;
  while (true) {
    if (x < a[i]) {
      break;
    } else {
      x -= a[i];
      i++;
      count++;
    }
  }
  if (x != 0) count--;
  cout << count << endl;
  return 0;
}
