#include <bits/stdc++.h>
using namespace std;
long long i, j, q;
long long n, m, p, k, t, f, s, v, h;
long long a, b, c, d;
long long x, y, z, w, l, r;
long long one = 1, zero = 0, ans = 0, cnt = 0;
long long mod = 1000000007;
long long INF = 9223372036854775807;
long long a1, a2, a3 = 0, a4, a5, a6, a7, a8;
string st1, st2, st3, st4;
char ch1, ch2, ch3;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  ifstream fin("Text.txt");
  cin >> n >> x;
  vector<long long> vc(n);
  for (i = 0; i < n; i++) cin >> vc[i];
  sort(vc.begin(), vc.end());
  i = 0;
  while (i < n && a1 + vc[i] <= x) {
    a1 += vc[i];
    i++;
  }
  if (x && i == n) i--;
  cout << i << endl;
  return 0;
}
