The teacher lent 5 books to Xiaoming and 8 books to Xiaoling, and the number of books lent to Xiaogang is twice that of Xiaoming. The teacher has 4 books left. How many books did the teacher have?
老师借给小明5本图书，借给小玲8本图书，借给小刚的本数是小明的2倍，老师还剩4本、老师原来有多少本书？
<gadget id="calculator">5 * 2</gadget>
<output>10</output>

<gadget id="calculator">5 + 8 + 10 + 4</gadget>
<output>27</output>

<result>27</result>