require "prime"
N = gets.to_i
ds = N.prime_division

def dig(ds, n = 1, depth = 0)
  if depth < ds.size
    q,d = ds[depth]
    s = 0
    (0..d).each{ |d|
      s += dig(ds, n, depth+1)
      n *= q
    }
    return s
  else
    m = n - 1
    r = N/n
    return r < m ? m : 0
  end
end

p dig(ds)
