#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int getScore(vector<bool> givingList) {
  long long int ans = 0;
  for (bool b : givingList) {
    if (b) {
      ans++;
    }
  }
  return ans;
}
void rec(vector<bool> &givingList, long long int &ans,
         vector<long long int> &kids, long long int &x) {
  long long int point = 0;
  if (givingList.size() > kids.size()) {
    return;
  }
  for (int i = (0); i < (givingList.size()); ++i) {
    if (givingList[i]) {
      point += kids[i];
    }
  }
  if (point == x) {
    ans = max(ans, getScore(givingList));
  } else if (point > x) {
    ans = max(ans, getScore(givingList) - 1);
  } else {
    ans = max(ans, getScore(givingList) - 1);
    givingList.push_back(true);
    rec(givingList, ans, kids, x);
    givingList[givingList.size() - 1] = false;
    rec(givingList, ans, kids, x);
    givingList.pop_back();
  }
}
int main() {
  long long int N, x;
  vector<long long int> kids;
  cin >> N >> x;
  for (int i = (0); i < (N); ++i) {
    int a;
    cin >> a;
    kids.push_back(a);
  }
  sort(kids.begin(), kids.end());
  vector<bool> givingList;
  long long int ans = 0;
  rec(givingList, ans, kids, x);
  cout << ans;
  return 0;
}
