Problem A of CodeForces 249