#include #include #include using lint = long long; constexpr lint INF = 1LL << 40; template std::vector vec(int len, T elem) { return std::vector(len, elem); } void solve() { int n; lint k; std::string s; std::cin >> n >> k >> s; auto dp = vec(40, vec(n, 0LL)); for (int i = 0; i < n; ++i) { lint get = 0, cnt = 1; for (int j = 0; j < n; ++j) { ++get; cnt += int(s[(i + j) % n] - '0') - 1; if (cnt == 0) break; } dp[0][i] = (cnt > 0 ? INF : get); } for (int j = 1; j < 40; ++j) { for (int i = 0; i < n; ++i) { if (dp[j - 1][i] == INF) { dp[j][i] = INF; } else { int ni = (i + dp[j - 1][i]) % n; dp[j][i] = std::min(dp[j - 1][i] + dp[j - 1][ni], INF); } } } lint ans = 0; int i = 0; for (int j = 39; j >= 0; --j) { if (dp[j][i] > k) continue; ans += (1LL << j); k -= dp[j][i]; (i += dp[j][i]) %= n; } std::cout << ans + (k > 0) << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }