solving problem 77