#include #include #include using namespace std; int main() { int n, k; string s; cin >> n >> k >> s; int rewardInABox = 0; for (int i = 0; i < n; ++i) { rewardInABox += (int)(s[i] - '0'); } int boxesToAnalyze = max(0, k - n * 2) / n; k -= n * boxesToAnalyze; int toBuyInABox = max(0, n - rewardInABox); int toBuy = toBuyInABox * boxesToAnalyze; int reward = 0; for (int i = 0; i < k; ++i) { if (reward > 0) { --reward; } else { ++toBuy; } reward += (int)(s[i % n] - '0'); } cout << toBuy << endl; return 0; }