#include <bits/stdc++.h>
using namespace std;
long long a, n, x, sum, X;
vector<int> v;
int main(void) {
  cin >> n >> X;
  for (x = 0; x < n; x++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  for (x = 0; x < n; x++) {
    sum += v[x];
    if (sum > X) {
      x--;
      break;
    }
    if (sum == X) {
      cout << x + 1 << "\n";
      return 0;
    }
  }
  if (x == n) x--;
  if (x < 0) x = 0;
  cout << x << "\n";
}
