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