#include <bits/stdc++.h>
using namespace ::std;
const long long maxn = 1e6 + 500;
const long long inf = 1e18 + 800;
const long long mod = 1e9 + 7;
long long a[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, x, sum = 0;
  cin >> n >> x;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    if (x <= a[i]) {
      x -= a[i];
    } else {
      cout << i;
      return 0;
    }
  }
  cout << n - 1;
}
