[AC] SPOJ/FCTRL2 (Ruby)