When one −NH2 group is acetylated, there is increase in mass by 42 units.
161+42n=371⇒n=5 , where n is the number of amino groups.
Let the formula of the compound be,
CxH2x+2+5N5
12×x+2×x+2+5+5×14=161
x=6
So, the compound is C6H19N5
Number of atoms per molecule = 6 + 19 + 5 = 30