http://www.e-olimp.com/ua/problems/37