#include <bits/stdc++.h>
long long arr[500000];
using namespace std;
const long long MAX = 5000002;
vector<long long> p;
unsigned long long phi[MAX + 1];
int main() {
  size_t found;
  long long c = 0, c1 = 1, c2 = 1, g = 1, h = 1, z = 4, k = 1, maxi = 1e10,
            msize, sum = 0, sum1 = 0, sumi = 0, sumf = 0, ans = 0;
  long long n, m, e, count = 0, a = 125, b, in, mod, gauss, mod1 = 0, euclid,
                     cx1 = 0, cx2 = 0, c101 = 0, c102 = 0;
  long long expo;
  string s1 = "", s20 = "", x = "", sx = "", second = "";
  bool t = 0, t1 = 0, t2 = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  if (sum == m)
    cout << n;
  else if (sum > m)
    cout << n - 1;
  else {
    sort(arr, arr + n);
    for (int i = 0; i < n; i++) {
      if (m - arr[i] >= 0) {
        c++;
        m -= arr[i];
      }
    }
    cout << c;
  }
}
