solve prob67 which is similar to 18