#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  long long ans = 0;
  long long i = 0;
  while (x >= a[i]) {
    x -= a[i];
    ans++;
    i++;
  }
  if (ans == 0) {
    cout << 0 << endl;
    exit(0);
  } else if (x == 0) {
    cout << ans << endl;
    exit(0);
  } else {
    for (long long j = 0; j < i; j++) {
      for (long long k = i; k < n; k++) {
        if (x + a[j] == a[k]) {
          cout << ans << endl;
          exit(0);
        }
      }
    }
  }
  cout << ans - 1ll << endl;
}
