#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; cin >> a[i]; i++) {
  }
  function<int(int, int)> solve = [&](int i, int x) {
    if (x < 0) {
      return INT_MIN;
    }
    if (i < 0) {
      if (x == 0) {
        return 0;
      }
      return -1;
    }
    return max(solve(i - 1, x), solve(i - 1, x - a[i]) + 1);
  };
  cout << solve(n - 1, x);
  return 0;
}
