Mr. Wang bought more pencils than 45 and less than 50. If the average distribution is given to 5 students, there are 2 left; if the average distribution is given to 9 students, there are still 2 left. How many pencils did Mr. Wang buy?
王老师买铅笔的数量比45多，比50少．如果平均分给5个同学，还剩2支；如果平均分给9个同学，也还剩2支．王老师买了多少支铅笔．
<gadget id="calculator">5 * 9</gadget>
<output>45</output>

<gadget id="calculator">45 + 2</gadget>
<output>47</output>

<result>47</result>