well, she really began with "x" total.
then she sold half of that, so hmmm 1/2 of "x" is just x/2 and she's left with half, so she sold x/2 and she was left only with x/2, and then she bought 17 more, we also know that she has 31 now, so
[tex]\stackrel{\textit{leftover}}{\cfrac{1}{2}x}~~ + ~~\stackrel{\textit{more bought}}{17}~~ = ~~\stackrel{\textit{now she has}}{31}\implies \\\\\\ \stackrel{\textit{multiplying both sides by }\stackrel{LCD}{2}}{2\left(\cfrac{x}{2}~~ + ~~17 \right)~~ = ~~2(31)}\implies x+34=62\implies \LARGE \begin{array}{llll} x=28 \end{array}[/tex]