s = input() if len(s) == 1 or not "A" in s or not "B" in s: print('0') else: print(s.count("A"))