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