#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long double PI = 3.14159265358979;
int main() {
  long long N, x;
  cin >> N >> x;
  long long can[N];
  for (int i = 0; i < N; i++) {
    cin >> can[i];
  }
  sort(can, can + N);
  long long ans = 0;
  while (x > 0) {
    x -= can[ans];
    ans++;
  }
  cout << ans - 1;
}
