#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9;
const double EPS = 1e-9;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int bitCount(long bits) {
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, x;
  long long sum = 0;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (int)n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  int ans = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < (int)n; ++i) {
    x -= a[i];
    if (x < 0) {
      ans = i - 1;
    }
  }
  if (x > 0) ans = n - 1;
  cout << ans << endl;
  return 0;
}
