#include #include #include using namespace std; int main() { int d; cin >> d; string c1, c8, c; cin >> c1 >> c8; c = string("xxxxxxx") + "xxxxxxx" + c1 + c8 + "xxxxxxx" + "xxxxxxx"; unsigned long long weekday = 0x0; for (size_t i = 0; i < c.size(); ++i) { weekday <<= 1; weekday |= (c[i] == 'x'); } int maxContinuousHolidays = 0; for (; d >= 0; --d) { unsigned long long paid = (1 << d) - 1; for (size_t i = 0; i <= c.size() - d; ++i, paid <<= 1) { if ((weekday | paid) == weekday) { unsigned long long newWeekday = weekday & ~paid; int continuousHolidays = 0; for (size_t k = 0; k < c.size(); ++k, newWeekday >>= 1) { if (newWeekday & 0x1) { maxContinuousHolidays = max(maxContinuousHolidays, continuousHolidays); continuousHolidays = 0; } else { ++continuousHolidays; } } maxContinuousHolidays = max(maxContinuousHolidays, continuousHolidays); } } } cout << maxContinuousHolidays << endl; return 0; }