#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  int i = 0;
  while (x >= a[i]) {
    if (i + 1 == n) {
      if (x != a[i]) break;
    }
    x -= a[i];
    ans++;
    i++;
  }
  cout << ans << endl;
}
