How can I find the total distance of a problem?