Hello!
Let's put this as a proportion below and solve.

To solve for HP, we can see that we multiplied 2 by 6 to get to 12. We can do the same for 3.
3(6)=18
Just to check, we can cross multiply.
2x=36
x=18
Now we add.
18+12=30
Therefore, there are 30 pencils.
I hope this helps!