The speed of a locomotive without any wagons attached to it is 40 kmph. It diminishes by a quantity which is proportional to the cube root of the number of wagons attached, i.e. the speed of the locomotive is 34 kmph when 27 wagons are attached. What is the maximum number of wagons that can be attached, so that speed does not go below 30kmph?