Oh, it's like the wolf and the eggs game from my childhood :)
Thanks!
This is my first project. I did it according to Denisov's book.