If x is the original number of cookies, she has x/2 left after giving half away. The 2/3 she gives to her teacher leaves 1/3 of x/2=x/6. She gives 2 to the bus driver so she now has x/6-2=12, so x/6=14 and x=84.
CHECK: after giving half away she has 42. She gives 2/3 away to her teacher, so she has 42-28=14 left and gives 2 to the driver, leaving 12. So the figures work out and she had 84 cookies to start with.