require "prime"

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

num = STDIN.gets.chomp.split(" ").map(&:to_i)[0]
array = divisors(num)
puts array[array.size/2-1] + array[array.size/2] - 2