Can someone help me solve this equation?

one bag contains x pencils
5 bags contain 5x pencils
after adding 3 pencils to each bag
total no of pencils = 5(x+3)
According to question,
5(x+3)=45
x+3=45/5
x+3=9
x=6
one bag contained 6 pencils before adding