#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; ll N, K; string s; vector sum; bool check(ll x) { ll cnt = x; ll re = x / N * sum[N] + sum[x % N]; while (re > 0 && cnt < K) { ll start = cnt % N; cnt += re; re = re / N * sum[N] + sum[start + re%N] - sum[start]; } if (cnt >= K) return true; else return false; } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ scanf("%lld %lld", &N, &K); cin >> s; sum.resize(2 * N + 1); for (ll i = 0; i < N; i++) { sum[i + 1] = sum[i] + (s[i] - '0'); } for (ll i = N; i < N * 2; i++) { sum[i + 1] = sum[i] + (s[i - N] - '0'); } ll l = 0; ll r = K + 5; while (r - l > 1) { ll mid = (l + r) >> 1; if (check(mid)) r = mid; else l = mid; } cout << r << endl; return 0; }