#include int main() { std::string str1, str2, str3; char str[32]; int ans = 0; int d; std::cin >> d; std::cin >> str1 >> str2; str3 += "xxxxxxxxxxxxxx"; str3 += str1; str3 += str2; for(int k = 0; k < 28; ++k) { strcpy(str, str3.c_str()); for(int i = k; i < k+d; ++i) { if( i >= 28 ) { break; } if( str[i] == 'x' ) { str[i] = 'o'; } else { goto label_1; } } for(int i = 14; i < 28; ++i) { if( str[i] == 'o' ) { for(int j = i+1; j <= 28; ++j) { if( str[i] != str[j] ) { ans = std::max(ans, j-i); i = j-1; break; } } } } label_1: ans = ans; } std::cout << ans << std::endl; return 0; }