#include #include #include #include using namespace std; typedef long long ll; int main() { ll N, K; string S, bS; cin >> N >> K >> S; if (K < S.size()) S.resize(K); bS = S; ll ans = 0; ll left = 0; ll counter = K; bool flag = true; while (counter != 0) { if (left == 0) { if (flag && ans != 0 && (K - counter) % N == 0) { ll T = K - counter; ans = ans * (K / T); counter = K % T; flag = false; continue; } ++ans; if (S.front() == '1') ++left; else if (S.front() == '2') left = left + 2; S.erase(S.begin(), S.begin() + 1); --counter; } else { while (!S.empty() && left != 0) { if (S.front() == '1') ++left; else if (S.front() == '2') left = left + 2; S.erase(S.begin(), S.begin() + 1); --counter; --left; } } if (S.empty() && counter != 0) S = bS; } cout << ans << endl; return 0; }