#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
 public:
  SegmentTree(int count) {
    n = count;
    data = std::vector<int>(2 * n, 0);
  }
  void increase(int idx) {
    idx += n;
    data[idx]++;
    while (idx > 1) {
      idx /= 2;
      data[idx] = data[2 * idx] + data[2 * idx + 1];
    }
  }
  int sum(int left, int right) {
    int ret = 0;
    left += n;
    right += n;
    while (left < right) {
      if (left & 1) ret += data[left++];
      if (right & 1) ret += data[--right];
      left >>= 1;
      right >>= 1;
    }
    return ret;
  }

 private:
  int n;
  std::vector<int> data;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = 1e7;
  vector<int> largest(n + 1), smallest(n + 1);
  iota(largest.begin(), largest.end(), 0);
  iota(smallest.begin(), smallest.end(), 0);
  for (int i = 2; i <= n; i++) {
    if (i == largest[i]) {
      for (int j = i; j <= n; j += i) {
        largest[j] = i;
        smallest[j] = min(smallest[j], i);
      }
    }
  }
  long long result = 0;
  cin >> n;
  SegmentTree st(n + 1);
  for (int i = 2; i <= n; i++) {
    int num = i;
    int co = 1;
    while (num > 1) {
      int s = largest[num];
      num /= s;
      int p1 = 1;
      int p2 = s;
      while (largest[num] == s) {
        num /= s;
        p1 = p2;
        p2 *= s;
      }
      co *= p2 - p1;
    }
    int x = i - 1 - co;
    result += x;
    int others = st.sum(0, n / smallest[i] + 1) - x;
    result += others * 2;
    if (smallest[i] != 2 && smallest[i] * 2 <= n) {
      int abc = st.sum(0, n / 2 + 1) - st.sum(0, n / smallest[i] + 1);
      result += abc * 3;
    }
    st.increase(smallest[i]);
  }
  cout << result << endl;
}

### Prompt

Please create a solution in CPP to the following problem:

You are given a positive integer n. Let's build a graph on vertices 1, 2, ..., n in such a way that there is an edge between vertices u and v if and only if <image>. Let d(u, v) be the shortest distance between u and v, or 0 if there is no path between them. Compute the sum of values d(u, v) over all 1 ≤ u < v ≤ n.

The gcd (greatest common divisor) of two positive integers is the maximum positive integer that divides both of the integers.

Input

Single integer n (1 ≤ n ≤ 107).

Output

Print the sum of d(u, v) over all 1 ≤ u < v ≤ n.

Examples

Input

6


Output

8


Input

10


Output

44

Note

All shortest paths in the first example: 

  * <image>
  * <image>
  * <image>
  * <image>
  * <image>
  * <image>



There are no paths between other pairs of vertices.

The total distance is 2 + 1 + 1 + 2 + 1 + 1 = 8.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
class SegmentTree {
 public:
  SegmentTree(int count) {
    n = count;
    data = std::vector<int>(2 * n, 0);
  }
  void increase(int idx) {
    idx += n;
    data[idx]++;
    while (idx > 1) {
      idx /= 2;
      data[idx] = data[2 * idx] + data[2 * idx + 1];
    }
  }
  int sum(int left, int right) {
    int ret = 0;
    left += n;
    right += n;
    while (left < right) {
      if (left & 1) ret += data[left++];
      if (right & 1) ret += data[--right];
      left >>= 1;
      right >>= 1;
    }
    return ret;
  }

 private:
  int n;
  std::vector<int> data;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = 1e7;
  vector<int> largest(n + 1), smallest(n + 1);
  iota(largest.begin(), largest.end(), 0);
  iota(smallest.begin(), smallest.end(), 0);
  for (int i = 2; i <= n; i++) {
    if (i == largest[i]) {
      for (int j = i; j <= n; j += i) {
        largest[j] = i;
        smallest[j] = min(smallest[j], i);
      }
    }
  }
  long long result = 0;
  cin >> n;
  SegmentTree st(n + 1);
  for (int i = 2; i <= n; i++) {
    int num = i;
    int co = 1;
    while (num > 1) {
      int s = largest[num];
      num /= s;
      int p1 = 1;
      int p2 = s;
      while (largest[num] == s) {
        num /= s;
        p1 = p2;
        p2 *= s;
      }
      co *= p2 - p1;
    }
    int x = i - 1 - co;
    result += x;
    int others = st.sum(0, n / smallest[i] + 1) - x;
    result += others * 2;
    if (smallest[i] != 2 && smallest[i] * 2 <= n) {
      int abc = st.sum(0, n / 2 + 1) - st.sum(0, n / smallest[i] + 1);
      result += abc * 3;
    }
    st.increase(smallest[i]);
  }
  cout << result << endl;
}

```