require'prime';n=gets.to_i;s=1;(n.gcd n*~-n/2).prime_division.each{|n,p|s*=(n**(p+1)-1)/~-n};p s