Works on input from problem 18