Solving an equation with parentheses