Anytime you have problem like this or something similar to this where some of the variable is not constant and is changing as you change some other variable ( in this case ro (density) is changing as x is changing) you need to use integrals to solve problem.
First (always do like this) you write what is the mass of the small part of rod that has length of dx (dx represents elementar length). You know that mass = density* volume which means we need to find elementar volume
Elementar volume for this rod is:
R^2*pi*dx (R^2*pi is surface of cross section of rod and when we multiply it with dx we get elementar volume - elementar cilinder)
dm (elementar mass) = ro*R^2*pi*dx
Now we have our elementar equation. All we need to do now is to integral both sides
[tex] \int\limits^m_0 {} \, dm = \int\limits^3_0 {R^2*pi*ro} \, *dx [/tex]
All you need to do now is to solve integral. (remember to express ro before solving right side, left side is simply equal to m).