So.. .at the beginning of the sale, there was a total of "x" pies
now, let's see what happened to those pies

so, we had "x"
then Mary took 2, she left x - 2
Kate took half of that (x-2)/2
then 10 were sold, and 14 leftover
if we subtract all those figures, and solve for "x",
we should get what "x" was, so

notice, if we subtract what Mary took, and Kate, and the sold and leftover, from the original "x", we would end up with no pies :)
so.. just solve for "x"