N = gets.to_i S = gets.chomp checked = Hash.new ans = 0 0.upto(N - 2) do |i| s = [] s << i if S[i] == 'A' s << i + 1 if S[i + 1] == 'A' if not checked[s] checked[s] = true ans += 1 end end puts ans