import scala.math.sqrt

object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextLong()
  val maxDivisor = sqrt(n).toLong
  val fact = factorization(n, 2, Seq()).sorted
  if (fact.length == 1) {
    println(n-1)
  } else {
    println(compose(fact).sum - 2)
  }

  def factorization(num: Long, divisor: Long, acc: Seq[Long]): Seq[Long] = {
    if (divisor > maxDivisor) {
      if (num == 1L) acc else acc :+ num
    } else if (num % divisor == 0L) {
      val nextAcc = acc :+ divisor
      factorization(num / divisor, divisor, nextAcc)
    } else {
      factorization(num, divisor + 1L, acc)
    }
  }

  def compose(acc: Seq[Long]): Seq[Long] = {
    if (acc.length == 2) {
      acc
    } else {
      val nextAcc = acc.slice(1,acc.length-1) :+ (acc.head * acc.last)
      compose(nextAcc.sorted)
    }
  }

}
