Solution for Code Chef Problem 'FCTRL2' (http://www.codechef.com/problems/FCTRL2)