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