#include <bits/stdc++.h>
using namespace std;
int mx8[] = {0, 0, 1, -1, -1, 1, -1, 1};
int my8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
int mx4[] = {1, -1, 0, 0};
int my4[] = {0, 0, -1, 1};
const int MOD = 1000000007;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n), sum(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int i = 0, cnt = 0;
  while (x > 0 && i < n) {
    if (x - a[i] >= 0) {
      x -= a[i];
      i++;
    } else
      break;
  }
  if (x != 0 && i > 0) i--;
  cout << i << endl;
}
