#include <bits/stdc++.h>
using namespace std;
int main() {
  using ll = long long int;
  ll N, x;
  cin >> N >> x;
  vector<ll> vec(N);
  for (ll i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  ll sum = 0;
  ll ans = 0;
  for (ll i = 0; i < N && sum + vec.at(i) <= x; i++) {
    sum += vec.at(i);
    ans++;
    if (i == N - 1) {
      if (sum != x) {
        ans--;
      }
    } else if (sum + vec.at(i + 1) > x) {
      ans--;
      for (ll j = i; j < N; j++) {
        if (sum - vec.at(i) + vec.at(j) == x) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}
