def gcd(a,b) if(b==0) then return a; end return gcd(b,a%b); end def s(n) ret = 1; i = 2; while (i*i <= n) do tmp = i; while (n%i == 0) do tmp *= i; n /= i; end ret *= (tmp-1) / (i-1); i += 1; end if n!=1 then i = n; tmp = i; while (n%i == 0) do tmp *= i; n /= i; end ret *= (tmp-1) / (i-1); end return ret; end n = gets.to_i; v = gcd(n, n*(n-1)/2); puts s(v);