import scala.io.StdIn._

object Main extends App {
  def div(n: Long, d: Int, divs: List[Long]): List[Long] = {
    if (d > 1000000) {
      (if (n == 1) divs else n :: divs)
    } else {
      (n % d) match {
        case 0 => div(n / d, d, d :: divs)
        case _ => div(n, d + 1, divs)
      }
    }
  }

  def mult(l: Long, r: Long, divs: List[Long]): (Long, Long) = {
    divs match {
      case Nil => (l, r)
      case x :: xs => if (l < r) mult(l * x, r, xs) else mult(l, r * x, xs)
    }
  }

  val (l, r) = mult(1, 1, div(readLong, 2, Nil))
  println(l + r - 2)
}