s and increment its count in the counter.\n3. Initialize a variable result to store the total number of substrings.\n4. Iterate over the counter and for each character frequency n, add n*(n+1)/2 to result.\n5. Return result as the final answer.\n