#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> kids(N);
  for (int i = 0; i < (int)(N); i++) {
    cin >> kids.at(i);
  }
  sort(kids.begin(), kids.end());
  int c = 0;
  int ans = 0;
  for (int kid : kids) {
    if (x >= kid) {
      x -= kid;
      ans++;
    } else {
      break;
    }
  }
  if (x > 0 && ans > 0) ans--;
  cout << ans << endl;
}
