#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; double w; }; ll MOD = 10000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { int N, K; cin >> N >> K; string S; cin >> S; int atari = 0, prev_atari = 0, buy = 0, prev_buy = 0, eat = 0, prev_eat = 0; for (;;) { for (int i = 0; i < N; i++) { if (eat >= K) { cout << buy << endl; return 0; } if (atari > 0) atari--; else buy++; atari += S[i] - '0'; eat++; } if (atari >= N) { cout << buy << endl; return 0; } if (atari == prev_atari) { int x = (K - eat) / (eat - prev_eat); buy += x * (buy - prev_buy); eat += x * (eat - prev_eat); } prev_atari = atari; prev_buy = buy; prev_eat = eat; } }