#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 counter = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (x > sum) counter++;
    else if (x == sum) {
      counter++
      break;
    }
    else {
      counter--;
      break;
    }
  }

  cout << counter << endl;
}