solution for problem 77