All the soldiers are arranged in the form of an equilateral triangle i.e., one soldier in the front and 2 soldiers in the second row and 3 soldiers in the third row, 4 soldiers in the fourth row and so on. If 669 more soldiers of another company are added in such a way that all the soldiers now are in the form of a square and each of the sides then contains 8 soldiers less than each side of the equilateral triangle. Initially, how many soldiers were there?