Jasper Yu says to YSITD
phi=(n-1)*(m-1)