The ratio of the number of Larry’s marbles to the number of John’s marbles was 3:5. In a game with their friends, Larry won 15 marbles while John lost 3 marbles. They both then had the same number of marbles. How many marbles did both boys have altogether before the game?

Larry's marbles ---- 3x

John's marbles ---- 5x

Larry won 15, now has 3x+15
John lost 3, now has 5x - 3

they are now equal
5x - 3 = 3x + 15
2x = 18
x = 9

Larry had 27 and john had 45