package main import ( "bufio" "fmt" "os" "strconv" ) func main() { sc := bufio.NewScanner(os.Stdin) sc.Buffer(make([]byte, 6+2+200000+2), 6+2+200000+2) sc.Scan() N, _ := strconv.Atoi(sc.Text()) sc.Scan() S := sc.Text() count := 0 count1 := 0 for i := 0; i+2 <= N; i++ { if S[i:i+2] == "BB" { count1 = 1 } else if S[i:i+2] != "AB" || i == 0 || S[i-1] == 'A' { count++ } } fmt.Println(count1 + count) }