#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int x;
  vector<long long int> arr;
  cin >> n >> x;
  for (int i = 1; i <= n; i += 1) {
    long long int y;
    cin >> y;
    arr.push_back(y);
  }
  sort(arr.begin(), arr.end());
  int c = 0;
  for (int i = 0; i < n; i += 1) {
    if (arr[i] <= x || arr[i] == 0) {
      x -= arr[i];
      c += 1;
    } else {
      break;
    }
  }
  if (x == 0) {
    cout << c;
  } else if (c == 0) {
    cout << c;
  } else {
    cout << c - 1;
  }
}
