Problem 6 Russian Version