Problem:
Score : 300 points

Problem Statement

Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7.

Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation:

Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward.

For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure.
If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward.
Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back.

Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.

Constraints

1 ≦ x ≦ 10^{15}

x is an integer.

Input

The input is given from Standard Input in the following format:

x

Output

Print the answer.

Sample Input 1

7

Sample Output 1

2

Sample Input 2

149696127901

Sample Output 2

27217477801

Solution in Scala (2.11.7) (judge verdict: Wrong Answer)

object Main {

  val scanner = new java.util.Scanner(System.in)

  def main(args: Array[String]): Unit = {
    val target = scanner.nextLong()
    val magicNumber = target % 11 + 11
    if (target < magicNumber) {
      val targets = List((target, 1), (target, 2), (target, 3), (target, 4), (target, 5), (target, 6))
      println(calc(targets, 0))
    } else {
      val targets = List((magicNumber, 5), (magicNumber, 6))
      println(calc(targets, 0) + (target - magicNumber) / 11 * 2 + 1)
    }
  }

  def calc(targets: List[(Long, Int)], acc: Int): Int = {
//    println(targets.sorted)
    val results = targets.map(x => (x._1 - x._2, x._2)).distinct.filter(_._1 >= 0)
    if (results.isEmpty) {
      0
    } else {
      if (results.exists(_._1 == 0)) {
        acc
      } else {
        val newTargets = results.flatMap(x => rotate(x._2).map(y => (x._1, y))).distinct
        calc(newTargets, acc + 1)
      }
    }
  }

  def rotate(current: Int): List[Int] = {
    List(
      rotateLeft(current),
      rotateRight(current),
      rotateForward(current),
      rotateBackward(current)
    )
  }

  def rotateLeft(current: Int): Int = current match {
    case 1 => 4
    case 2 => 4
    case 5 => 4
    case 6 => 4
    case 3 => 1
    case 4 => 6
  }

  def rotateRight(current: Int): Int = current match {
    case 1 => 3
    case 2 => 3
    case 5 => 3
    case 6 => 3
    case 3 => 6
    case 4 => 1
  }

  def rotateBackward(current: Int): Int = current match {
    case 1 => 5
    case 3 => 5
    case 4 => 5
    case 6 => 5
    case 2 => 1
    case 5 => 6
  }

  def rotateForward(current: Int): Int = current match {
    case 1 => 2
    case 3 => 2
    case 4 => 2
    case 6 => 2
    case 2 => 6
    case 5 => 1
  }
}