Given a sequence of coins where each coin shows H (heads) or T (tails), return the minimum number of flips needed to make the sequence "beautiful" — that is, all H's come before all T's (the form HH...TT...). An all-H or all-T sequence is also beautiful.
Input
coins: an array of characters or values representing the coin sequence
Output
The minimum number of flips required.
Examples
Example 1
Inputcoins = [1, 2, 3, 4, 5]
Output0
Example 2
Inputcoins = [10, 20]
Output0
Constraints
1 <= coins.length <= 10^5.