Figured out solution for problem 3.

6857