package main import . "fmt" import . "strings" func main() { var n,s string Scan(&n,&s) var c int if Contains(s,"BB") { c++ } for _,x:=range Split(s,"B") { if len(x)>1 { c+=len(x)-1 } } c+=Count(s,"AB") c+=Count(s,"BA") c-=Count(s,"BAB") Println(c) }