require 'prime'
N = gets.to_i

primes = Prime.prime_division(N)
a, b = 1,1
primes.reverse.each do |list|
  i = list[0]
  list[1].times do
    if a <b
      a *= i
    else
      b *= i
    end
  end
end

puts (a-1)+(b-1)