In this solution you start with a red ball, which subtract 2 from A and triggers ablue ball. The first blue ball subtract another one and triggers a second blue ball.
The second blue ball adds one to the right and triggers a red ball which is just the same.
If A is less than 3 at any red ball the process will stop either with the red or with the next blue.
So if A=3, you’ll need 4 balls. A=6 - 7 balls