Editorial for Mock CCC '18 Contest 3 J3/S1 - A String Problem
Submitting an official solution before solving the problem yourself is a bannable offence.
This problem admitted a couple solutions. The easiest one to reason about is a brute force where you pick the characters you don't delete and delete the rest, and track the minimum count.
A more efficient solution would be to note that the two characters you don't want to delete are the two most frequent ones. You can accumulate these counts and report the sum of all but the two largest. Be wary of the case where the string only contains one distinct letter.