The cyclization of cyanogen chloride (I) with aqueus methylamine (II) at 150 C in a pressure vessel gives N2,N4,N6-trimethylmelamine (III), which is then treated with aqueous formaldehyde at pH 8.9.
Treatment of alcohol (I) with methanesulfonyl chloride in the presence of triethylamine provided mesylate (II), which was condensed with the spirosubstituted piperidine (III) to give the desired compound.