Problem 6. From Imo'2018 | AMiner