This invention is directed to compounds of formula (I): where n, m, Y, R1, R2, R3, R4 and R5 are disclosed herein, as isolated stereoisomers or mixtures thereof, or as pharmaceutically acceptable salts thereof; pharmaceutical compositions comprising the compounds of formula (I); and methods of using the compounds and the pharmaceutical compositions in treating diseases or conditions associated with JAK2 activity.