require 'prime'
N = gets.chomp.to_i

M = 1
L = 1

factors = N.prime_division.to_a.reverse
whichs = true

factors.each do |e|
  while e[1] >= 1 do
    if whichs
      M = M * e[0]
      e[1] = e[1] - 1
      whichs = false
    else
      L = L * e[0]
      e[1] = e[1] -1
      whichs = true
    end
  end
end


puts (L + M -  2)
