#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  auto sm = accumulate(a.begin(), a.end(), 0LL);
  if (sm <= x) {
    if (sm == x) {
      cout << n << endl;
    } else {
      cout << n - 1 << endl;
    }
    return 0;
  }
  vector<long long> vec(x + 1, 0);
  vector<long long> lef, rig;
  for (auto it = a.begin(); it != a.end(); ++it) {
    for (auto i = x; i > -1; --i) {
      if (i - *it < 0) break;
      vec[i] = max(vec[i - *it] + 1, vec[i]);
    }
  }
  cout << *max_element(vec.begin(), vec.end()) << endl;
  return 0;
}
