There are a total of 40 red, yellow or blue balls in a box. Each ball is marked with a number out of 1, 2, 3 and 4 on the side. The figure in the shaded area below each shows the number of balls in that category. For example, the number of red balls marked with the number "1" is 12. What is the minimum number of balls to be taken out of the box to ensure that you have at least one ball of each color and each marked number?
