Melissa's family has just moved to a new house and she is excited to start painting her bedroom walls. After coming up with a great design, she realizes that she will need to ask her parents to fund the project. Wanting to seem independent, she would prefer to ask her parents for as little money as possible. Can you help her figure out how much money she will need to pay the painters?
Melissa's paint design is given as a grid of colours arranged in rows and columns. The painters will paint the wall in 2x2 blocks and will charge Melissa $1 for every unique colour in a 2x2 block.
Input
A test case begins with two integers , , and are even). The next lines contain characters, each representing a unique colour.
Output
Output one integer, the cost of the paint job.
Sample Input
2 2
RG
BR
Sample Output
3
Sample Input
4 4
WWRB
WWRR
WWRR
WBBB
Sample Output
7
Explanation of Sample Input/Output
In the second case, the painters will paint the wall in four blocks:
WW RB WW RR
WW RR WB BB
Making the total cost .
Comments