#include using namespace std; #define ll long long #define all(x) x.begin(),x.end() #define rep(i,a,b) for(int i=a;i<=b;i++) #define rep_r(i,a,b) for(int i=a;i>=b;i--) #define each(a,x) for (auto& x : a) using pi = pair; using pl = pair; using vi = vector; using vl = vector; #define sz(x) int(x.size()) #define so(x) sort(all(x)) #define so_r(x) sort(all(x),greater()) #define lb lower_bound #define ub upper_bound const char nl = '\n'; int dx[4] = {1,-1,0,0}; int dy[4] = {0,0,1,-1}; int bit_cnt(int x){ return __builtin_popcount(x); } ll bex(ll a, ll b, ll mod = 1e9 + 7){ll res = 1LL; while(b){ if (b&1) res = res * a % mod; a = a * a % mod; b >>= 1;} return res;} template bool chmax(t&a,u b){if(a bool chmin(t&a,u b){if(b one_box(){ int buy = 0; int remain = 0; rep(i,1,n){ buy++; int j = i; int prize = s[i-1] - '0'; while (prize && j < n) { prize--; j++; if (j > i) prize += s[j-1] - '0'; } i = j; remain = prize; } return {buy, remain}; } int find1(int k){ int buy = 0; if (k == 0) return 0; rep(i,1,n){ buy++; int j = i; int prize = s[i-1] - '0'; while (prize && j < n) { prize--; j++; if (j > i) prize += s[j-1] - '0'; } i = j; if (i >= k) return buy; } return n; } void solve(){ cin >> n >> k >> s; pair p = one_box(); int buy = p.first, remain = p.second; // cout << buy << ' ' << remain << nl; if (k <= n) { cout << find1(k) << nl; return; } if (k > n && remain >= buy){ cout << buy << nl; return; } // extra buy times we need to spend for full fill other box int next_buy = buy - remain; ll boxes = k / n; // total full-boxes we need to buy ll still = k % n; // number of icecream still need to buy ll ans = 1 * buy + next_buy * (boxes - 1) + max(find1(still) - remain, 0); cout << ans << nl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--){ solve(); } }