You are given a string
$S$ consisting of lowercase latin letters '
$a$' & '
$b$' only. Your task is to minimize the size of the string by applying the following three operations as many times as you wish. At a time, you can apply only one operation.
This is a companion discussion topic for the original entry at https://toph.co/p/compressed-string