#K69537. Minimum Flips to Unify Coins

    ID: 33108 Type: Default 1000ms 256MiB

Minimum Flips to Unify Coins

Minimum Flips to Unify Coins

You are given a series of coins, where each coin is represented by either H for heads or T for tails. Your task is to determine the minimum number of flips required so that all coins show the same side.

The optimal strategy is to flip all coins that form the minority group. In other words, if there are n coins showing heads and m coins showing tails, then the answer is:

min(n,m)\min(n, m)

Note that the input will be provided as a single line, in which the coin states are separated by spaces. Your solution should read from standard input and output the result to standard output.

inputFormat

The input consists of a single line containing coin states separated by spaces. Each state is either H or T.

For example:

H T H H T

outputFormat

Output a single integer representing the minimum number of flips required to make all coins the same.

## sample
H H H
0