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