Solving two step algebraic equations