PROGRAM ATCODER

implicit none
integer(16) :: n,i,s_n,ans=0

read*, n

s_n = int(sqrt(real(n,8)),16) + 1

do i = 1, s_n, 1
  if ( mod(n,i) == 0 ) then
    if ( i /= 1 ) then
      if ( mod(n,i-1) == n/(i-1) ) then
        ans = ans + (i-1)
      end if
    end if
    if ( n/i /= 1 ) then
      if ( mod(n,n/i-1) == n/(n/i-1) ) then
        ans = ans + (n/i-1)
      end if
    end if
  end if
end do

print'(i0)', ans

END PROGRAM ATCODER