Copying problem81 as a template
Solution