Anastasia is the first to choose the integer and she chooses $A = 2$.
Anastasia should first reach a status where there's a number of pebbles left less than $B$.
To achieve this, on every Anastasia's turn we can say that there are
$B + n$ pebbles left
As long as $n > 2$, she can play whatever number.
When $n \leq 2$ Anastasia must play the correct number: if $n = 2$ she plays $1$, else if $n = 1$ she plays $2$.
The status after this move is either $B + 1$ or $B - 1$ and it's Barnabas' turn. He cannot win at this turn (because $B \geq 3$) and after his turn we have less than $B$ pebbles left.
Anastasia should now just make sure that after her turn there's an even number of pebbles left, so that Barnabas' can't win. On the last turn there's just 1 pebble left and it's Anastasia's turn.