The exchange rate
— n equals m over capital-M — is the most-used line in all of high-school chemistry, and it is pure shopping. If apples cost 2 dollars each and you spent 18 dollars, you bought 9 apples: you divided the total by the price of one. Molar mass is the price of one mole, in grams. Divide your grams by it and out comes your headcount.
Which way up? Let the units settle it, and let them settle it ONE WAY only: cancels the grams and leaves mol, so the division is right side up. If a rearrangement's units refuse to cancel into the answer's units, that rearrangement is wrong, no appeal. Units that DO work out never prove you right — the check is a one-way street. And the sanity rail: your answer in moles should be a friendly, human-sized number, because M is roughly the number of nucleons in one particle, and your sample is roughly a spoonful.