solved safety in numbers, codejam 2012 round 1B