The Novák family baked wedding cakes. They delivered a quarter to relatives in Moravia, gave a sixth to colleagues at work, and gave a ninth to neighbors. If they had three more cakes left, it would be half of the original number of cakes. How many cakes did they bake?