let n = read_int ()
let i, ans = ref 1, ref 0
let f m = if m > 0 && n / m = n mod m then ans := !ans + m
let _ =
  while !i * !i <= n do if n mod !i = 0 then (f @@ !i - 1; f @@ n / !i - 1); incr i done;
  Printf.printf "%d\n" !ans