ll@n,y=0,z=0; string@s; rep(i,n-1){ y|=s[i]=='B'&&s[i+1]=='B'; z+=(s[i]=='A'||s[i+1]=='A')&&!(i>=1&&s[i-1]=='B'&&s[i+1]=='B'); } wt(y+z);