#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_skip() while(*rp++>=48) #define wt(v) {ulong _z=v;do*--wp=_z%10+48;while(_z/=10);} typedef unsigned long ulong; ulong f1(){ char*mmap(); char*rp=mmap(0l,1l<<25,1,2,0,0ll); rd_skip(); long d=1,y=1,b=0,a=*rp++; for(long c;c=*rp++,c>='A';){ if(c!=a){ if(d==1||c!=b){ b=a; ++d; } else{ b^='R'^'G'^'B'^a; --d; ++y; } a=c; } } return y+d*2/3; } void f2(ulong z){ char wbuf[64],*wp=wbuf+sizeof wbuf; wt(z); write(1,wp,wbuf+sizeof wbuf-wp); } int main(){ f2(f1()); _exit(0); }