There were some balls in Boxes X, Y and Z. For every 3 balls in Box X, there were 7 balls in Box Y. For every 5 balls in Box Y, there were 6 balls in Box Z. After 54 balls were transferred from Box Y to Box X, the ratio of the number of balls in Box X to the number of balls in Box Y to the number of balls in Box Z became 12:13:21. Find the total number of balls in the three boxes.

x:y = 3:7 = 15:35

y:z = 5:6 = 35:42
x:y:z = 15:35:42

x/y = 3/7
(x+54)/(y-54) = 12/13
x:y:z = 90:210:252
90+210+252 = 552