Fourth problem solution