Solving problem 1