count number of repeated characters in string java