Start by converting mg to g. There is .001g in every miligram, so there is 0.4g in this sample.
Then find the molar mass of ibuprofen (C13H18O2) which is 206.3g/mol
Then divide grams by the molar mass to get moles of C13H18O2: (0.4g)/(206.3g/mol) = 1.94x10^-3mol C13H18O2
Then multiply moles by Avogadro's number to get molecules: (1.94x10^-3mol)/(6.02x10^23) = 1.17x10^21 molecules of ibuprofen (C13H18O2)