#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
map<long long, int> memo;
const int MAX_N = 100;
int N;
long long x;
long long A[MAX_N];
int solve() {
  int answer = 0;
  int j = 0;
  sort(A, A + N);
  for (int i = (0); i < (N); i++) {
    if (x < A[i]) break;
    x -= A[i];
    answer++;
    j = i;
  }
  if (x == 0)
    return answer;
  else {
    for (int i = (0); i < (j + 1); i++) {
      for (int k = (j + 1); k < (N); k++) {
        if (x + A[i] == A[k]) return answer;
      }
    }
    return max(0, answer - 1);
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> x;
  for (int i = (0); i < (N); i++) cin >> A[i];
  cout << solve() << "\n";
  return 0;
}
