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 } else { c-=len(x) } } c+=Count(s,"AB") c+=Count(s,"BA") Println(c) }