Let's call A the initial amount of water, in liters, in that barrel.
After y liters were spilled, the amount left was
A - y
Then, after 6 liters were added, the final remaining amount was given by:
A - y + 6
Now, since x liters remain, we have:
x = A - y + 6
Therefore, if we can find the expression for the initial amount of water, in liters, by isolating A in that equation:
x = A - y + 6
x + y = A + 6
x + y - 6 = A
A = x + y - 6
Thus, the initial amount of water was (x + y - 6) liters.