Check curly braces with a stack