#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, i, a[101], count = 0;
  cin >> n >> x;
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = 0; i < n; i++) {
    if (x < a[i])
      break;
    else {
      x -= a[i];
      count++;
    }
  }
  if (x != 0) count--;
  cout << count << endl;
}
