Task from Codeforces 212