You'd need to use the substring function within a loop and check each character, no time to check the syntax, but something like this
my_string = "BBB12BBB";
do for i = 1 to length(my_string);
if substr(my_string,i,1) = "B" then count+1;
end;
Another alternative:-
first_count = length(my_string)
new_string = compress(my_string,'B');
second_count = length(new_string);
Number_of_bs = first_count - second_count;
Enjoy.