problem 1194 (improved)