#include <iostream>
using namespace std;
int main() {
int n;
unsigned long long k;
cin>>n>>k;
int arr[n];
int basearr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
basearr[i]=arr[i];
}
unsigned long long walls=0;
bool hecan=true;
while(hecan){
for(int i=0; i<n; i++){
if(k>=arr[i]){
k-=arr[i];
arr[i]+=basearr[i];
walls++;
}
else {
hecan=false;
break;
}
}
if(!hecan)break;
else{
for(int i=n-1; i>=0; i--){
if(k>=arr[i]){
k-=arr[i];
arr[i]+=basearr[i];
walls++;
}
else{
hecan=false;
break;
}
}
}
}
cout<<walls;
return 0;
}
Copy