Balls are arranged in rows to form an equilateral triangle (1 in the first row, 2 in the second, and so on). If 669 more balls are added, all the balls can be arranged in a square and each side of the square contains 8 balls fewer than the number of balls on a side of the triangle. What was the initial number of balls?