Balanced parenthesis problem