My version of first additional task.

By Lemax1995 (Lemax on edu.mmcs.sfedu.ru).