#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long int x;
  cin >> N >> x;
  vector<long long int> a(N);
  long long int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long int count = 0;
  int ans = 0;
  int k;
  for (int i = 0; i < N; i++) {
    if (x - count >= a[i]) {
      count += a[i];
      ans++;
    } else {
      k = i;
      break;
    }
  }
  count -= a[k];
  ans--;
  for (int i = k; i < N; i++) {
    if (count + a[i] == x) {
      ans++;
      break;
    }
  }
  cout << ans << endl;
}
