object Main {
  def main(args: Array[String]): Unit = {
    val lines = io.Source.stdin.getLines()
    lines foreach (n => println(pi(n.toInt)))
  }
  def pi(n: Int): BigInt = {
    if (n < 2) 0
    else if (n == 2) 1
    else if (n == 3) 2
    else
      (3 to n).map {i =>
        val fi = factorial(i - 2)
        fi - i * (fi/i)
      }.sum - 1
  }
  def factorial(n: Int): BigInt = {
    def aux(x: Int, n: Int): BigInt = {
      if (n <= 16) (x+1 until x+n).product
      else {
        val i = n/2
        aux(x, i) * aux(x+1, n-i)
      }
    }
    aux(1, n)
  }
}