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