Solution of codeforces.ru