#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, x;
int a[100100];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int ans = 0;
  bool was = 0;
  for (int i = 1; i <= n; ++i) {
    if (x >= a[i]) {
      was = 1;
      x -= a[i];
      ans++;
    }
  }
  if (x != 0 && was) ans--;
  cout << ans << endl;
}
