in reply to Faster way to do this?

by faster you mean fewer keystrokes?
$string='IIIIIIIIIIIMMMMMMMMMMMMOOOOOOOOOOOOMMMMMMMMMIIIIIIIII'; print $count=$string=~s/M/M/g;