beads.cc - updated for usaco, not sure if it passes as uscao is down but it works on the given testcase, may need to work on corner cases (all red beads, all white, all blue)