https://barzunov.ru/2015/01/begin11/
Решение задачи Begin11