#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n + 1];
  int count = 0;
  for (int i = 0; i < n; i++) {
    int an;
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] > a[j]) {
        int tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      count++;
      x -= a[i];
    } else if (i == (n - 1) && count != 0 && x != 0) {
      count--;
      break;
    } else {
      break;
    }
  }
  cout << count << endl;
  return 0;
}
