#include <bits/stdc++.h>
using namespace std;
long long n, ar[100004], x;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar, ar + n);
  long long cur = 0;
  while (cur < n && x >= ar[cur]) {
    x -= ar[cur];
    cur++;
  }
  if (x != 0) {
    bool found = false;
    for (int i = cur; i < n; i++) {
      for (int j = 0; j < cur + 1; j++) {
        if (x + ar[j] == ar[i]) {
          found = true;
          break;
        }
      }
      if (found) break;
    }
    if (!found) cur--;
  }
  cout << cur << endl;
  return 0;
}
