import sys input = sys.stdin.readline N=int(input()) S=input().strip() ans=1 if "BB" in S else 0 for i in range(1,N): if S[i-1:i+1]!="BB": if i==1 or S[i-2:i+1]!="BAB": ans+=1 print(ans)