Grammar ambiguous or not?
Here is an outline of a parsing procedure. To prove that the grammar is unambiguous, you have to show that it works (parses the string), and furthermore that the parsing tree it produces is the unique one generating the string. If this question came up in the context of a course on compilers, then you should have learned the necessary tools.

The parser is a DPDA. The stack starts initialized with S, and then works according to the following rules, reading the input from left to right.


If the top-of-stack is S:


If the string starts aa, replace S with AS (S on top).
If the string starts ab, replace S with BS.
If the string starts and ends a, reject.
If the string ends, accept.
If the string starts b, delete S and process b again.

If the top-of-stack is A:


If the string starts b, delete A.
Otherwise, reject.

If the top-of-stack is B:


If the string starts b, replace B with S.
Otherwise, reject.



(Unless explicitly stated, the automaton consumes the characters it reads from the string.)
At the end of parsing, the automaton rejects unless the stack is empty.

I'll let you figure out how to construct the actual parse tree. You'll also have to figure out how to prove that this parsing tree is the unique one (if it is indeed the case).