#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  vector<int> v;
  cin >> n >> x;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int a;
    sum += a;
    cin >> a;
    v.push_back(a);
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= v[i]) {
      ans++;
      x -= v[i];
    }
  }
  if (ans == n) {
    ans -= 1;
  }
  cout << ans << endl;
  return 0;
}
