#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  vector<int> dp(n + 1, INT_MAX);
  dp[0] = 0;
  long long sum = 0;
  for (int rep = 0; rep < n; ++rep) {
    int want;
    scanf("%d", &want);
    sum += want;
    for (int i = n - 1; i >= 0; --i) {
      if (dp[i] == INT_MAX) {
        continue;
      }
      dp[i + 1] = min(dp[i + 1], dp[i] + want);
    }
    debug() << " ["
            << "dp"
               ": "
            << (dp) << "] ";
  }
  int answer = 0;
  while (answer + 1 <= n && dp[answer + 1] <= x) {
    ++answer;
  }
  if (answer == n && sum != x) {
    answer--;
  }
  printf("%d\n", answer);
}
