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 Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static public class FenwickTree {
		int N;
		int[] t;

		public FenwickTree(final int N) {
			t = new int[N + 1];
			this.N = N;
		};

		public void add(int i, final int v) {
			if (i > N)
				return;
			i = Math.max(i, 1);
			for (int j = i; j <= t.length; j += j & -j)
				t[j - 1] += v;
		}

		public int cumsum(int i) {
			int s = 0;
			for (int j = i; 0 < j; j -= j & -j)
				s += t[j - 1];
			return s;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.valueOf(sc.next());
		int M = Integer.valueOf(sc.next());

		FenwickTree cumSum = new FenwickTree(M);
		FenwickTree indCountSum = new FenwickTree(M);
		int[] numByLength = new int[M + 1];
		Map<Integer, ArrayList<Integer>> startIndexListByLen = new HashMap<Integer, ArrayList<Integer>>();

		for (int i = 1; i <= N; i++) {
			int l = Integer.valueOf(sc.next());
			int r = Integer.valueOf(sc.next());
			int length = r - l + 1;
			cumSum.add(length, 1);
			numByLength[length] += 1;
			if (!startIndexListByLen.containsKey(length))
				startIndexListByLen.put(length, new ArrayList<Integer>());
			List<Integer> list = startIndexListByLen.get(length);
			list.add(l);
		}

		sc.close();

		for (int length = 1; length <= M; length++) {
			int smallerLength = length - 1;
			if (startIndexListByLen.containsKey(smallerLength)) {
				List<Integer> list = startIndexListByLen.get(smallerLength);
				for (int x : list) {
					indCountSum.add(x, 1);
					indCountSum.add(x + smallerLength, -1);
				}
			}
			
			int s1 = 0;
			for (int k = 0; k <= M; k += (length))
				s1 += indCountSum.cumsum(k);
			int s2 = cumSum.cumsum(M) - cumSum.cumsum(length - 1);
			System.out.println(s1 + s2);
		}
	}
}