#include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, k; std::cin >> n >> k; std::vector s(n); int buyNum = 0; int freeNum = 0; int ans = 0; for(int i=0; i> input; s[i] = input - '0'; } for(int i=0; i=k){ ans = buyNum; }else{ ans += buyNum + std::max((buyNum-freeNum)*(k/n-1), 0); for(int i=0; i<(k%n); ++i){ if(freeNum == 0){ ++ans; }else{ --freeNum; } freeNum += s[i]; } } std::cout << ans << "\n"; return 0; }