#include <bits/stdc++.h>
const int N = 110;
int a[N], n, m;
inline int work() {
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int j;
    for (j = i; j <= n; ++j)
      if (a[j] == m) break;
    if (a[j] == m) {
      m -= a[j];
      ans++;
      break;
    } else if (m >= a[i]) {
      m -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (m != 0 && ans > 0) ans--;
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    std::random_shuffle(a + 1, a + n + 1);
    ans = std::max(ans, work());
  }
  printf("%d\n", ans);
  return 0;
}
