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