r+r+3+r+12
3r+15, let r=1
3+15=18, so we need each person to have 6
we know that g=12+1=13, f=3+1=4, r=1
So g must give away 7. f must take 2, and r must get 5
So 7+2+5=14 got exchanged in total.
But I can see that only $7 dollars was taken to be distributed to the other two as well.