N = int(input()) S = input() ans = 0 for i in range(len(S) - 1): if S[i] == "A": if S[i+1] == "A": ans += 1 else: if i > 0 and S[i-1] == "A": ans += 1 else: if S[i+1] == "A": ans += 1 print(ans)