URI -- 1609 (Counting Sheep)

Solution :