#include <bits/stdc++.h>
using namespace std;
bool sort_by(pair<int, int> c, pair<int, int> d) { return c.second < d.second; }
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a;
  int b;
  for (int i = 0; i < N; i++) {
    cin >> b;
    a.push_back(b);
  }
  sort(a.begin(), a.end());
  int index = 0;
  while (index < (int)a.size() && a[index] <= x) {
    x -= a[index];
    ++index;
  }
  if (x == 0)
    cout << index;
  else
    cout << max(--index, 0);
}
