calculateManhattanDistance function

Calculates the manhattan distance.