R3 interview question

Write a method that counts the brackets nesting and finds the deepest one.