## Task A-1.2.

Gargamel has caught $N$ Smurfs and distributed them into three bags. When Papa Smurf was moved from the first bag to the second, Grouchy from the second to the third, and Smurfette from the third to the first, the average height of the Smurfs in the first bag decreased by 8 millimeters, while the average heights of the Smurfs in the second and third bags increased by 5 millimeters and 8 millimeters, respectively.

If there were nine Smurfs in the first bag, determine $N$.