#include <iostream>
using namespace std;
int main() {
int n,p;
cin >> n >> p;
int cnt = 0;
int arr[n];
for (int i = 0;i < n;i++) {
cin >> arr[i];
}
for (int i = n - 1;i >= 0;i--) {
if (p > arr[i]) {
cout << 0;
while(arr[i]<p){
p -= arr[i];
cnt++;
}
}
}
cout << cnt;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: