#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, X;
  int cnt = 0, sum = 0;
  int a[100];
  cin >> n >> x;
  X = 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]) {
      cnt++;
      x -= a[i];
    } else
      break;
  }
  if (sum < X)
    cout << n - 1 << endl;
  else if (sum == X)
    cout << n << endl;
  else
    cout << cnt << endl;
  return 0;
}
