Based on the law of conservation of mass, mass is neither created nor destroyed.
In the given, sugar is mixed with water, and since there is no loss from any type, therefore, the total final mass will be equivalent to the summation of the mass of water and the mass of sugar.
Based on the above:
mass of solution = mass of water + mass of sugar
mass of solution = 500 + 2 = 502 grams