#include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define FFOR(i,a,b) for(int i=(a);i<=(b);i++) #define REP(i,b) FOR(i,0,b) #define RREP(i,b) FFOR(i,1,b) #define PB push_back #define F first #define S second #define BE(c) c.begin(),c.end() using namespace std; typedef long long LL; typedef LL ut; typedef long double ld; typedef pair pr; typedef vector Vpr; typedef vector VI; typedef pair ppr; typedef priority_queue > PQ; const int SIZE=1e+5 + 1; const ut INF=1<<29; const ld eps=1e-6; const LL mod=1e+6 + 3; int main() { int n, k; string s; cin >> n >> k >> s; int now = 0, f = 0, cnt = 0; int ans = 0; bool end = false; do{ ans++; int c = s[now] - '0'; do { if(f > 0){ c = s[now] - '0'; f--; } if(c == 1){ f++; } else if(c == 2){ f += 2; } now++; cnt++; if(ans == 1 && now >= n && f != 0){ end = true; now = 0; break; } if(k <= cnt){ now = 0; break; } now %= n; }while(f != 0); }while(now != 0); if(end){ cout << ans << endl; return 0; } ans = ans * (k / cnt); int p = k % cnt; if(!p){ cout << ans << endl; return 0; } cnt = 0; end = false; do{ ans++; char c = s[now]; do { if(f > 0){ c = s[now]; f--; } if(c == '1'){ f++; } else if(c == '2'){ f += 2; } now++; cnt++; if(p <= cnt){ end = true; break; } now %= n; }while(f != 0); }while(!end); cout << ans << endl; return 0; }