Answer: A is 6 and B is 6
Explanation: From the formula of glucose we can see that the number of hydrogen and Oxygen isn't balance. In order to balance we add 6 before water. Thus we have 12 hydrogen ,18 oxygen and 6 C on the RHS.
The number of oxygen is not balanced on the LHS thus we add 6 before O2 , making the oxygen to amount to 16.
You can only find the value of B when you balance the left hand side also. Trying to find B by just sticking to the LHS will lead to a wrong value. So it is preferable to try balancing the whole equation.
Hope my answer doesn't confuse you.