Replace occurence of a character

How can I replace multiple occurrence of a character in a string with single character and return how many times that value is counted. If we are given a string "KABOOOON", it should count how many times each character is repeated and return the count for each character in MSB. For example {0, 'K'},{0,'A'},{0,'B'},{1,'O'}-4-4 indicates that character is repeated 4 times