open Printf open Scanf
open Array

let divisors n = (* O(sqrt n) *)
  let rec f0 i a =
    if i*i > n then a
    else if i*i = n && n mod i = 0 then i::a
    else if n mod i = 0 then f0 (i+1) (i::(n/i)::a)
    else f0 (i+1) a in f0 1 []

let factors n = (* O(sqrt n) *)
  let m = ref n in
  let tbl = Hashtbl.create ~random:true 30000 in
  for i=2 to 2 + (int_of_float @@ sqrt @@ float_of_int @@ n) do
    if !m mod i = 0 then (
      let k = ref 0 in
      while !m mod i = 0 do
        k := !k + 1; m := !m / i;
      done;
      Hashtbl.add tbl i !k;
    )
  done;
  if !m>1 then (Hashtbl.add tbl !m 1);
  let res = make (Hashtbl.length tbl) (0,0) in
  ignore @@ Hashtbl.fold (fun p k idx -> res.(idx) <- (p,k); idx+1) tbl 0;
  res

let () = scanf " %d" @@ fun n ->
  let a = divisors n in
  print_int @@
    List.fold_left (fun sum v ->
      let m = v - 1 in
      if m > 0 && n / m = n mod m then (
        sum + m
      ) else sum
    ) 0 a


