There is already an answer on the link you posted, but I will try to solve it here.
"On the day after Halloween, Kabir had 5 times as much candy as Sam. If Kabir gives 18 pieces of candy to Sam, they will each have the same amount. How many pieces of candy do they have in all?"
If we make a variable for the number of candies Sam has, s, we can put everything in terms of s when we solve this. Because we know that Kabir had 5 times as much candy as Sam, we can make that expression:
5x = Kabir's candy
Now, we can figure out the second equation needed to figure out the answer. If Kabir gives Sam 18 candies, they will have the same amount. So:
5x - 18 = 3x
(I got 3x by dividing the total amount of candy by two, because they will have the same amount of candy once the exchange is done)
Now, we can solve the equation for x.
5x - 18 = 3x
(Subtract 3x from both sides)
2x - 18 = 0
(Add 18 to both sides)
2x = 18
(Divide both sides by 2)
x = 9
Now we can figure out the total amount by multipling x by 6. As I said above, the total amount of candy is 6x.
So:
6x = Total
6 * (9) = Total
56 = Total
The total amount of candy that both boys have is 56 pieces of candy.