A market gardener was planting a new orchard. The young trees were arranged in rows so as to form a square, and it was found that there were trees unplanted. To enlarge the square by an extra row each way, he had to buy additional trees. How many trees were in the orchard when it was finished?