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