require 'prime'
N = gets.to_i
pds = Prime.prime_division(N)
 
divs = []
pds.each do |pd|
  pd[1].times{divs.push(pd[0])}
end
 
a, b = 1, 1
divs.sort.reverse.each do |div|
  if a <= b
    a *= div
  else
    b *= div
  end
end
p a + b - 2