#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, ans = 0;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  do {
    int xx = x;
    int count = 0;
    for (int i = 0; i < N; ++i) {
      if (xx >= a[i]) {
        if (i != N - 1 || a[i] == xx) {
          xx -= a[i];
          count++;
        } else {
          break;
        }
      } else {
        break;
      }
    }
    ans = max(ans, count);
  } while (next_permutation(a.begin(), a.end()));
  cout << ans << endl;
}
