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