#include #include #include using namespace std; int cal(string s){ int ret=0, cnt=0; for(int i=0; i> D; string c1, c2; cin>> c1>> c2; auto str=c1+c2; auto C=string(14, 'x')+str+string(14, 'x'); auto B=C; reverse(B.begin(), B.end()); int ans=-1; for(int i=0; i<=42-D; i++){ auto s=C.substr(0, i), t=B.substr(0, i); int d=D; while(d){ if(C.substr(i, d)==string(d, 'x')){ s+=string(d, 'o'); break;} d--; } d=D; while(d){ if(B.substr(i, d)==string(d, 'x')){ t+=string(d, 'o'); break;} d--; } for(int j=s.size(); j<42; j++){ s+=C[j]; t+=B[j]; } ans=max(ans, max(cal(s), cal(t))); } cout<< ans<< endl; return 0; }