Length and Cost Calculation