open Printf open Scanf
open Array

let divisors n = (* O(sqrt n) *)
  let tbl = Hashtbl.create ~random:true 30000 in
  let rec f0 i =
    if i*i > n then ()
    else if i*i = n && n mod i = 0 then Hashtbl.add tbl i i
    else if n mod i = 0 then (
      Hashtbl.add tbl i i;
      Hashtbl.add tbl (n/i) (n/i);
      f0 (i+1)
    ) else f0 (i+1)
  in f0 1;
  let res = make (Hashtbl.length tbl) 0 in
  ignore @@ Hashtbl.fold (fun _ v idx -> res.(idx) <- v; idx+1) tbl 0;
  res

let () = scanf " %d" @@ fun n ->
  let a = divisors n in
  print_int @@
    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


