#include #include #include #include #include #include #define REP(i, n) for(int i=0;i<(n);i++) using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int D; cin >> D; std::array arr; REP(i, 14) { cin >> arr[i]; } vector> days; int i = 0; int j = 0; for(auto d: arr) { if (d == 'o') { if (j > 0) { days.emplace_back('x', j); j = 0; } i++; } else { if (i > 0) { days.emplace_back('o', i); i = 0; } j++; } } if (i > 0) { days.emplace_back('o', i); i = 0; } if (j > 0) { days.emplace_back('x', j); j = 0; } int idx = 0; int m = 0; while (idx < days.size()) { if (days[idx].first == 'o') { int k = days[idx].second; if (idx + 1 < days.size()) { k += min(D, days[idx+1].second); if (days[idx+1].second <= D && idx + 2 < days.size()) { k += days[idx + 2].second; } } m = max(m, k); idx++; } else { int k = 0; if (days[idx].second <= D) { k += days[idx].second; if(idx + 1 < days.size()) { k += days[idx + 1].second; } } else { k += D; if (idx + 1 < days.size()) { k += days[idx + 1].second; } } m = max(m, k); idx++; } } if (days[0].first == 'o') { m = max(m, D + days[0].second); } if (days[days.size() - 1].first == 'o') { m = max(m, D + days[days.size() - 1].second); } cout << m << endl; return 0; }