#include using namespace std; #define REP(i,first,last) for (int i=first;i y ? x : y) #define MIN(x,y) (x < y ? x : y) int N, K; int main(){ cin >> N >> K; vector ice_box(N); REP(i,0,N){ cin >> ice_box[i]; } int atari = 0; int buy = 0; int idx = 0; int eat = 0; while (true) { idx %= N; if (atari > 0) { --atari; } else { ++buy; } ++eat; atari += ice_box[idx] - '0'; if (eat + atari >= K) break; ++idx; } cout << buy << endl; }