Lets convert all '$ab$
' to '$bb$
' as they can be minimized to '$b$
'. Then as a result we will get one of the three types of strings after applying operations.
$aaa...a$
' then the minimized string will be '$a$
'.$bbb...b$
' then the minimized string will be '$b$
'.$bbb...a$
' then the minimized string will be '$ba$
'.