#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n >> x;
  int input, count = 0;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < (n); ++i) {
    if (x - a[i] >= 0) {
      x -= a[i];
      count++;
    }
  }
  if (x > 0 && count > 0) count--;
  cout << count << endl;
}
