#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const long long inf = 2e9, MOD = 998244353, MAX = 1e7 + 2;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int res = 0;
  for (int i = 0; i < n; i++)
    if (a[i] <= x) x -= a[i], res++;
  cout << res;
}
