object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toInt
  val prime = primes(n + 2)
  var count = 0
  for (i ← 1 until prime.size){
    if (prime(i) == prime(i - 1) + 2) {
      count += 2
    }
  }
  println(count)
  def primes(upper:Int): Array[Int] = {
    val memo = Array.tabulate(upper + 1){_ ⇒ true}
    for (i ← 2 to math.sqrt(upper).toInt){
      if (memo(i)){
        for (j ← i * 2 to upper by i){
          memo(j) = false
        }
      }
    }
    (2 to upper).filter(it ⇒ memo(it)).toArray
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
