#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000000 + 7;
const long long INF = 9e18;
const double PI = 3.14159265358979323846;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
int main() {
  int N;
  int x, ans = 0;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i : a) {
    if (x >= i) {
      ans++;
      x -= i;
    } else {
      break;
    }
  }
  if (x > 0 && ans != 0) ans--;
  cout << ans << endl;
  return 0;
}
