This is a codeshef problem Level Of Difference. [Solution 2]