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