#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_skip() while(*rp++>=48) #define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;}) char t[500004]; long f(char*s){ while(*s){ char*u=t; while(*(long*)s==*(long*)u){ s+=sizeof(long); u+=sizeof(long); } while(*s==*u){ ++s; ++u; } ++u; while(*(long*)s==*(long*)u){ s+=sizeof(long); u+=sizeof(long); } while(*s==*u){ ++s; ++u; } if(*s++!=10){ return 0; } } return 1; } int main(){ char*mmap(); char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd_skip(); long m=rd(); long j=0; char*s1=rp; char*s2=rp+(m+1); long v; while(v=*(long*)(s1+j),v==*(long*)(s2+j)){ *(long*)(t+j)=v; j+=sizeof(long); } while(s1[j]==s2[j]){ t[j]=s1[j]; ++j; } long r=48; t[j]=s1[j]; memcpy(t+(j+1),s2+j,m-j); r+=f(rp); t[j]=s2[j]; memcpy(t+(j+1),s1+j,m-j); r+=f(rp); write(1,&r,1); _exit(0); }