**Physical Address**

304 North Cardinal St.

Dorchester Center, MA 02124

Little Malvika is very peculiar about colors. On her birthday, her mom wanted to buy balloons for decorating the house. So she asked her about her color preferences. The sophisticated little person that Malvika is, she likes only two colors — amber and brass. Her mom bought **n** balloons, each of which was either amber or brass in color. You are provided this information in a string **s** consisting of characters ‘a’ and ‘b’ only, where ‘a’ denotes that the balloon is amber, where ‘b’ denotes it being brass colored.

When Malvika saw the balloons, she was furious with anger as she wanted all the balloons of the same color. In her anger, she painted some of the balloons with the opposite color (i.e., she painted some amber ones brass and vice versa) to make all balloons appear to be the same color. As she was very angry, it took her a lot of time to do this, but you can probably show her the right way of doing so, thereby teaching her a lesson to remain calm in difficult situations, by finding out the minimum number of balloons needed to be painted in order to make all of them the same color.

- The first line of input contains a single integer
**T**, denoting the number of test cases. - The first and only line of each test case contains a string
**s**.

- For each test case, output a single line containing an integer — the minimum number of flips required.

**1**≤**T**≤**100****1**≤**n**≤**100**, where**n**denotes to the length of the string**s**.

**Input:**
3
ab
bb
baaba
**Output:**
1
0
2

**In the first example**, you can change amber to brass or brass to amber. In both the cases, both the balloons will have same colors. So, you will need to paint 1 balloon. So the answer is 1.

**In the second example**, As the color of all the balloons is already the same, you don’t need to paint any of them. So, the answer is 0.

```
#include <iostream>
#include <string>
using namespace std;
void Give_me_the_Min(string input){
int a=0,b=0;
for(int i =0;input[i];i++){
if(input[i] == 'a')
a++;
}
for(int i = 0;input[i];i++){
if(input[i] == 'b')
b++;
}
if(a<b)
cout << a << endl;
else
cout << b << endl;
}
int main() {
// your code goes here
int test_cases;
cin >> test_cases;
string input;
for(int i = 0;i<test_cases;i++){
cin >> input;
Give_me_the_Min(input);
}
return 0;
}
```

```
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
static int frr(String a)
{
int i;
int k=0;
int j=0;
int p;
for(i=0;i<a.length();i++)
{
if(a.charAt(i)=='a')
{
k++;
}
if(a.charAt(i)=='b')
{
j++;
}
}
p=k>j?k:j;
return p;
}
public static void main (String[] args) throws java.lang.Exception
{
Scanner obj=new Scanner(System.in);
int i;
int size;
size=obj.nextInt();
String str[]=new String[size];
for(i=0;i<size;i++)
{
str[i]=obj.next();
}
for(i=0;i<size;i++)
{
int l=0;
l=frr(str[i]);
System.out.println(str[i].length()-l);
}
}
}
```

```
n=int(input())
for i in range(n):
x=input()
a=x.count('a')
b=x.count('b')
print(min(a,b))
```

In our experience, we suggest you solve this Malvika is peculiar about color of balloons CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Malvika is peculiar about color of balloons CodeChef Solution

I hope this Malvika is peculiar about color of balloons CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Coding Solutions >>**