#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to;
  int cost;
};
long long gcd(long long a, long long b) {
  long long r;
  while ((r = a % b) != 0) {
    a = b;
    b = r;
  }
  return b;
}
long long lcm(long long a, long long b) { return (a / gcd(a, b) * b); }
int main(void) {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (x > 0) {
    ans--;
  }
  cout << max(ans, (long long)0);
  return 0;
}
