import sys def main(): input = lambda: sys.stdin.readline()[:-1] N = int(input()) S = "_" + input() ans = int("BB" in S) for i in range(1, N): if S[i : i + 2] == "BB" or S[i - 1 : i + 2] == "BAB": continue ans += 1 print(ans) if not __debug__: f = open(sys.argv[1], "r") sys.stdin = f main()