#include<bits/stdc++.h>
using namespace std;
int n, m;
int c[19], v[19];
bool dfs(int x, int num) {//第x头牛,分为num组
for (int i = 1; i <= x && i <= num; i++) {//小于组数
if (v[i] + c[x] <= m){//小于每组容量
v[i] += c[x];
if (x == n) return 1;
if (dfs(x + 1, num)) return 1;
v[i] -= c[x];
}
}
return 0;
}
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> c[i];
}
int l = 1, r = n;//二分优化
while (l < r) {
memset(v,0,sizeof(v));
int mid = l + r >> 1;
if (dfs(1, mid))r = mid;
else l = mid + 1;
}
cout << l;
return 0;
}