Calculation of required speed