#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  int ans = 0;
  while (x >= 0) {
    x -= a.at(ans);
    if (x >= 0) {
      ans++;
    }
    if (ans >= N) {
      break;
    }
  }
  cout << ans << endl;
}
