If you use the equation F=ma and re-arrange it to get m = F/a, you'll get the total mass. Then you have to subtract the mass of the cart from the total mass to get the mass of the rock.
Thus, m = 6N over 2m/s^2. The total mass will then be 3kg. Subtracting 1kg from the total mass will then yield you 2kg, which is the mass of the rock. Hope this helps.