Correct solution to Code Forces Round #451 Problem B.

Had some trouble with solving this one.