A boat sails for 5 miles in one direction, turns 45° to its right and sails 5 miles in that direction, turns again 45° to its right and sails 5 miles and so on. How many miles does it sail before returning to the starting position?