#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, x, sum = 0, count = 0;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(), a.end());
  if (x > sum) count--;
  for (int i = 0; i < N; i++) {
    if (a[i] <= x) {
      x -= a[i];
      count++;
    } else
      break;
  }
  cout << count << endl;
}
