One day, Resty gets a very interesting puzzle. Eve said that she will make a cake for Resty if he solved this puzzle, so Resty asks you to help him to solve the puzzle as soon as possible.
As the figure, the puzzle is a rectangle divided into 4 * 6 = 24 squares. Each cell has a color of white / black/ grey. There are exactly 8 cells of each color. Our purpose is to make the middle 8 cells(which are not on the edge) have the same color by minimal steps.
Each step, you could choose a row or a column to shift it for 1 bit. As following:
Now, given the puzzle, you should help Resty find the minimal steps he must use to solve it.