Calculate number of occurrence of a char in string