#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  scanf("%d%d", &N, &x);
  vector<int> stk;
  while (N--) {
    int foo;
    scanf("%d", &foo);
    stk.push_back(foo);
  }
  sort(stk.begin(), stk.end());
  int ans = 0;
  for (auto& it : stk) {
    if (x - it >= 0) ++ans, x -= it;
  }
  printf("%d", ans - (ans == N && x == 0 ? 0 : 1));
  return 0;
}
