n = gets.to_i sn = n * (n - 1) / 2 t = Math.sqrt(n).to_i res = 0 t.times do |x| x += 1 if n % x != 0 || sn % x != 0 then next end res += x ax = n / x if ax != x && sn % ax == 0 then res += ax end end puts res