program divertaD
	integer 
    integer(2) i, N, sum
    read(*, *) N
    sum = 0
    DO 10 i = 1, N
     if (mod(N,i).NE.0) then
      if (((N-mod(N,i))/i).EQ.(mod(N,i))) then
      sum = sum + i
      end if
     end if
    10 continue
    print '(i0)', sum
end program