#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } const int m=40; signed main(){ int n;ll k;cin>>n>>k; string s;cin>>s; vector> p(n,vector(m+1,0)),b(n,vector(m+1,0)); vector> to(n,vector(m+1,0)); rep(i,n){ b[i][0]=1; p[i][0]=s[i]-'0'; to[i][0]=(i+1)%n; } auto merge=[&](ll p_l,ll p_r,ll b_l,ll b_r){ auto p_m=p_r+max(0ll,p_l-b_r); auto b_m=b_l+max(0ll,b_r-p_l); return make_pair(p_m,b_m); }; for(int j=0;j>i)&1){ tie(P,B)=merge(P,p[cur][i],B,b[cur][i]); cur=to[cur][i]; } } cout<