Solving 2 variables for optimal numbers

Okay say I have 5,000 white cubes, and I want to paint them either red or blue, but the paints cost differently: red paint costs $200, and blue paint costs $600. I want as many blue colored cubes as possible while still having enough money left over for red cubes, and all 5,000 cubes must be either red or blue by the time I have no money left over. I have $2,000,000. What is the optimal number of red/blue cubes if I want as many blue cubes as possible?

This is what I have so far:

(#red cubes*$200) + (#blue cubes*$600) = $2,000,000

#red cubes + #blue cubes = 5,000

How would I go about solving this