require 'complex'

n = gets.to_i
to = Math.sqrt(n)

remain = n

nums = []

while remain.even?
  nums << 2
  remain /= 2
end

i = 3
while remain >= i ** 2
  # puts i
  if (remain % i).zero?
    nums << i
    remain /= i
  end
  i += 2
end
if remain != 1
  nums << remain
end

a = 1
b = 1
nums.each_with_index do |k, i|
  if i.even?
    a *= k
  else
    b *= k
  end
end

# puts nums

puts a + b - 2
