S-Topcoder Round 14 Problem 3